EmbDev.net

Forum: µC & Digital Electronics How write to CH552 data flash


von Bert V. (Company: CruzPro Ltd.) (bertp)


Attached files:

Rate this post
useful
not useful
I would like so me help writing to CH552 data flash.  I am able to write 
and read to/from standard flash memory but when I try to write to 0xC000 
to 0xC0FF the CH552 reboots continuously.

I tried just reading from 0xC000-0xC0FF without writing and the CH552 
still reboots continuously.

I have attached a text file showing how I try to write to data flash. 
This works OK if writing to flash below 16K.

Regards,

Bert

von Thomas Z. (usbman)


Rate this post
useful
not useful
Bert V. wrote:
> I tried just reading from 0xC000-0xC0FF without writing and the CH552
> still reboots continuously.

reading the dataflsh does not work with movc, movc > 0x3FFF gives a 
reset
1
//flashaccess must be already activated
2
uint8_t ReadDataFlash(uint8_t addr, uint8_t *value)
3
{
4
   if((value) && (addr < 128))
5
   {
6
      ROM_ADDR = DATA_FLASH_ADDR | (addr < 1);
7
      ROM_CTRL = ROM_CMD_READ;
8
      if(ROM_STATUS & bROM_CMD_ERR) return 0xFE; // cmd error
9
      *value = ROM_DATA_L;
10
      return 0;                                  // success
11
   }
12
   return 0xFF;                                  // param error  
13
}
writefunction is similar to the above

: Edited by User
von Bert V. (Company: CruzPro Ltd.) (bertp)


Rate this post
useful
not useful
Thank you Thomas,

Works very well.

Best Regards,

Bert

von Thomas Z. (usbman)


Rate this post
useful
not useful
there is a typo in my routine:

 ROM_ADDR = DATA_FLASH_ADDR | (addr << 1); //only even access

sorry for that

von Bert V. (Company: CruzPro Ltd.) (bertp)


Rate this post
useful
not useful
I figured that out :-)

I have been testing the DataFlash with an endurance test.  The CH552 
user manual states it's good for 10,000 writes.  It's still working 
after over 200,000 write/read cycles.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.