Other Parts Discussed in Thread: CC1310
Tool/software: Code Composer Studio
Hi!
one of my lib functions, that are working fine on the CC1310 fail on the CC1312R1. I tried get closer to the error, but it seems to appear often, but randomly:
The routine uses the flash-driver from the driverlib and the latest releases of everything.
The routines from the CC1312R1 driverlib: FlashSectorErase() and FlashProgram() often return an error (although they did what I want, but not always)...
Thanks for your assistance,
Jo
(Btw.: D02/03 RX/TX are changed on the Launchpad-CC1312 to CC1310 ?? )
int16_t writeToCPUFlash(uint32_t dest_adr, uint8_t *psrc, uint32_t size, uint8_t flags){
int16_t result=0; // Assume OK
if(size && !memcmp((uint8_t*)dest_adr,psrc,size)){
return 0; // Already OK (makes sense e.g. if only FF is written an empty sector
}
if(AONBatMonBatteryVoltageGet()< MIN_VDD_CPU_FLASH) return -138; // Voltage too low!
VIMSLineBufDisable(VIMS_BASE);
VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED);
while(VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED);
CPUcpsid();
for(;;){ // dummy loop for cleanup
if(FlashProtectionGet(dest_adr)==FLASH_WRITE_PROTECT){ // Make sure that sector isn't write protected.
result = -102; // Write portected
#ifndef DEBUG_M
break;
#endif
}
/* Optionally Erase a flash Page */
if(flags & CFLASH_FLAG_ERASE){
if(dest_adr&(CFLASH_SECTOR_SIZE-1)){
result = -105; // Illegal Adr
break;
}
if(FlashSectorErase(dest_adr)!= FAPI_STATUS_SUCCESS){
result = -136; // Erase failed
#ifndef DEBUG_M
break;
#endif
}
}
/* Optionally Write to flash */
if(flags & CFLASH_FLAG_WRITE){
if(FlashProgram(psrc, dest_adr, size) != FAPI_STATUS_SUCCESS){
result = -137; // Write failed
#ifndef DEBUG_M
break;
#endif
}
}
/* Optionally verify, saves ca. 30 Bytes if not used */
if(flags & CFLASH_FLAG_VERIFY){
if(memcmp((uint8_t*)dest_adr,psrc,size)){
result = -138; // Verify failed
break;
}
}
break;
}
CPUcpsie();
VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
VIMSLineBufEnable(VIMS_BASE);
#ifdef DEBUG_M
if(result){
my_printf("A:%x F%d: L:%d Res:%d\n",dest_adr,flags,size,result);
result=0; // ignore!
}
#endif
return result; // 0: OK
}