This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I use CCS to build a project. The running space of the program is between 0x4400 and 0xFFFF. I want to write 1100 bytes of data to the address of 0x10000. I use the function "__data20_write_char" writes 20 bytes at a time. When I finish writing, use the function "__data20_ read_char" When reading char, it is found that there are random check errors in several bytes in the middle area. Here is my code:
int ota_write(unsigned long offset,const unsigned char *pdata,unsigned int size) { unsigned int i=0; for(i=0;i<size;i++) { __data20_write_char(offset+0x10000+i,pdata[i]); } for(i=0;i<size;i++) { if(__data20_read_char(offset+0x10000+i)!=pdata[i]) { DBG_LOG("CHK ERR"); //Several random byte check failures return -1; } } return 0; } static unsigned char test_buf[20]={0}; void test_fram() { int i=0,j=0;; for(i=0;i<55;i++) { for(j=0;j<sizeof(test_buf);j++) { test_buf[j]=j; check+j; } if(ota_write(i*sizeof(test_buf),test_buf,sizeof(test_buf))!=0) {return ;} } }
Please help me analyze what the problem is.
int ota_write(unsigned long offset,const unsigned char *pdata,unsigned int size) { unsigned int i=0; for(i=0;i<size;i++) { __data20_write_char(offset+0x10000+i,pdata[i]); } for(i=0;i<size;i++) { if(__data20_read_char(offset+0x10000+i)!=pdata[i]) { DBG_LOG("CHK ERR"); //Several random byte check failures return -1; } } return 0; } static unsigned char test_buf[20]={0}; void test_fram() { int i=0,j=0;; for(i=0;i<55;i++) { for(j=0;j<sizeof(test_buf);j++) { test_buf[j]=j; check+=j; //fixed } if(ota_write(i*sizeof(test_buf),test_buf,sizeof(test_buf))!=0) {return ;} } }
code fixed
**Attention** This is a public forum