Hi all,
Using a Pico 2 I have two memory arrays defined as :
So ALLROM_SIZE is 32K.
Further down my program I have some initialization code that should be clearing the memory out :
The code for CkSum16 isYou would expect the calculated checksum to be the same for both ReadRAM and WriteRAM, e.g. 0 as the memory has just been cleared?
Well ReadRAM is indeed 0 but WriteRAM seems to return a nonzero value, which seems odd considering the memset() line?
Any idea what is going on here?
Those areas are used as buffers that are DMA'd into / from by state machines, however this is before the state machines or the DMA have been initialised so nothing else should be accessing the variables.
This is most odd....
Cheers.
Phill.
Using a Pico 2 I have two memory arrays defined as :
Code:
#define BASICROM_SIZE (1024*16)#define PAGE_SIZE (1024*8)#define CART_SIZE (PAGE_SIZE*2)#define ALLROM_SIZE (BASICROM_SIZE+CART_SIZE)volatile uint8_t _Alignas(ALLROM_SIZE) ReadRAM[ALLROM_SIZE]; // Reads come from herevolatile uint8_t _Alignas(ALLROM_SIZE) WriteRAM[ALLROM_SIZE]; // buffer for mirrored/patched Basic ROM + mirrored / loaded CartRAMFurther down my program I have some initialization code that should be clearing the memory out :
Code:
memset((void *)ReadRAM,0,ALLROM_SIZE); memset((void *)WriteRAM,0,ALLROM_SIZE); printf("ReadRAM csum=%04X\n",CKSum16((uint8_t*)ReadRAM, ALLROM_SIZE)); printf("WriteRAM csum=%04X\n",CKSum16((uint8_t*)WriteRAM, ALLROM_SIZE));The code for CkSum16 is
Code:
uint16_t CKSum16(uint8_t *Base, uint32_t Count){ uint16_t Result = 0; uint32_t Index; uint32_t Words = Count / 2; for(Index=0; Index<Words; Index+=2) { Result = Result + (Base[Index] << 8) + Base[Index+1]; } return Result;}Well ReadRAM is indeed 0 but WriteRAM seems to return a nonzero value, which seems odd considering the memset() line?
Any idea what is going on here?
Those areas are used as buffers that are DMA'd into / from by state machines, however this is before the state machines or the DMA have been initialised so nothing else should be accessing the variables.
This is most odd....
Cheers.
Phill.
Statistics: Posted by PhillHS — Sat Feb 14, 2026 1:52 pm — Replies 3 — Views 99