W801

Anything not related to STM32
User avatar
Just4Fun
Posts: 28
Joined: Thu Dec 19, 2019 10:45 am
Answers: 1

Re: W801

Post by Just4Fun »

Just for fun ( :lol: ) I've done an Arduino Due sized PCB using a W806 and called it Azz!Duino ( :mrgreen: ):

Image

The PCB allows two options: PSRAM and external 9-12V supply.

I've just soldered a first board (no option installed) and it seems work as expected:

Image

Image

I'll publish all the details when ready, just in case...
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

that's impressive.

i'm done with my arduino port and i will post it later. liked the chip very much. wished it was more positioned as a microcontroller vs. a microprocessor. but for free, i'm not complaining.
User avatar
Just4Fun
Posts: 28
Joined: Thu Dec 19, 2019 10:45 am
Answers: 1

Re: W801

Post by Just4Fun »

I was quite annoyed by the "manual" upload requiring pressing the RST button twice ( :lol: ), so I did "a walk" inside Arduino IDE and the tools used in the W80x "core" to find a solution and.... I found it!

First of all only the W801 based board on Aliexpress has the needed reset circuitry (you can check on the schematics I have previously posted) , the other one based on the W806 miss completely that circuitry so can be uploaded only "manually" (on my board I followed for compatibility the same circuitry of the W806 based board, so the automated upload works as well)

You have to modify the platform.txt file inside the Arduino IDE local folder (in my system is located at "C:\Users\Fabius\AppData\Local\Arduino15\packages\w80x_duino\hardware\XT804\0.0.2", so adapt the path to your system), adding the -rs rts option to the following line (it's probably the last one):

Code: Select all

tools.serial_upload.upload.pattern="{cmd.path}" {upload.params.verbose} {serial.port} -ws 115200 -ds {upload.speed} -dl "{build.path}/{build.project_name}.fls"
as shown in the following screenshot:

Image

Now close Arduino IDE (if open) and re-run it. All done!

Now pressing the Upload button of the Arduino IDE the upload is fully automated (as for any Arduino board).

At this point there is another "annoying" detail that need to be fixed... the Serial Monitor behavior.
When you open the Arduino IDE Serial Monitor it "freezes" at reset the board because it activates the RTS signal.
To avoid that you have to add the line "w80x.serial.disableRTS=true" just after the line "w80x.name=w80x_duino" in the boards.txt file inside the Arduino IDE local folder (in the same folder of platform.txt) as shown in the following screenshot:

Image

Now close Arduino IDE (if open) and re-run it. That too is gone...

Enjoy!
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

I used the oem tool for w801 and just needed to add a switch for auto reset.

yes, you will need to find a serial monitor that allows disabling rts. otherwise the chip is held in reset. a small cap should have fixed that.
User avatar
Just4Fun
Posts: 28
Joined: Thu Dec 19, 2019 10:45 am
Answers: 1

Re: W801

Post by Just4Fun »

I've just published all the details to build the Azz!Duino board here.

Image

BTW: I haven't had time to play with the PSRAM. The PSRAM can be used as SPI or QSPI and on the board is connected for QSPI (but probably can be used as SPI as well).
User avatar
Just4Fun
Posts: 28
Joined: Thu Dec 19, 2019 10:45 am
Answers: 1

Re: W801

Post by Just4Fun »

At last I got the PSRAM working! :)

I've done a demo for Arduino IDE here.

BTW: There isn't any trace of PSRAM in the W806 SDK. You have to search over the W801 SDK...
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

The documentation is generally quite poor. It is almost as if they didn't want you to use their product.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

I managed to publish my w801 Arduino clone here: https://github.com/dannyf00/Arduino-Clone-for-W801-W806

I also wrote a small piece about the LSI calibration feature of this chip here: https://dannyelectronics.wordpress.com/ ... libration/

the uncalibrated LSI (for this particular chip) is 10% off. However, once it is calibrated (automatically to boot), it is almost spot on. I wish more chips have this feature built in. quite impressive.

I am going to manually calibrate a STM32F103 chip to see how that works.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

I am going to manually calibrate a STM32F103 chip to see how that works.
I ran the same code on a STM32F103.
1. the LSI (nominal 40Khz, and spec'd from 30K - 60Khz) runs at 37.108Khz.
2. the HSI (nominal 8Mhz, spec'd to 1%) runs at 7.9805 - 7.9810Mhz. or 0.2%, without triming. Trimming step is about 30Khz / increment, vs. 40Khz/increment suggested by the datasheet. so triming HSITRIM to 17 slightly improves the accuracy.

I did my test manually but you should be able to write a piece of code to find the optimal HSITRIM value and store it in one of the backup storage area, or the flash.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: W801

Post by dannyf »

you should be able to write a piece of code to find the optimal HSITRIM value
my 5-min attempt at this :)

Code: Select all

//tune LSI frequency
//Ftgt: the target frequency used to tune LSI
//return: the calculated F_LSI
uint32_t LSItune(uint32_t Ftgt) {
	uint8_t cnt=0;						//tycle counter
	uint32_t flsi_now=F_LSI, flsi_last;			//initialize flsi
	uint32_t ftgt=Ftgt;
	uint32_t tmp;

	do {
#if 1											//for debugging
		//for debug only
		//display the frequency
		tmp = flsi_now;							//item to be displayed
		tmp = tmp % 10000;						//display the last four digits
		//tmp = (tmp / 10000) % 10000;			//display the first four digits
		lRAM[3]=tmp % 10; tmp /=10;
		lRAM[2]=tmp % 10; tmp /=10;
		lRAM[1]=tmp % 10; tmp /=10;
		lRAM[0]=tmp % 10; tmp /=10;
		//end display
#endif
		flsi_last=flsi_now;						//update flsi
		rtcInit(RCC_BDCR_RTCSEL_LSI, flsi_last);	//initialize the rtc
		ftgt=rtcTicks(4)/4;						//average ftgt over a period of time
		flsi_now=Ftgt * flsi_last / ftgt;		//update the new flsi
		if (flsi_now==flsi_last) break;		//exit if two consecutive measurements are the same
	} while (cnt++<16);							//exit for overtime
	return flsi_now;
}

Putting aside the (led) display driver I put there for debugging - my bluepill doesn't have any other way to communicate with the outside world, short of a stlink, the code is straight forward.
1. we configure the rtc to run on LSI, and use the initialize LSI frequency as the starting point.
2. we measure the master clock (I used HSE but HSI will work as well, or even with PLL), average it over a period of time (4 seconds in this case).
3. we then calculate the right F_LSI is.
4. if they are not the same, we iterate.

The computer found a slightly different value for me (37110hz, vs. 37108hz). Not a real difference.
Post Reply

Return to “Off topic”