Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I have a calling routine (read32reg) that passes a readBuffer to routine (readfromspi). In the readfrom spi routine I do receive correct data (4 bytes) from the device. However, when I pass the array back to read32reg (which have correct values 0x01 0x30 0xCA 0xDE), "buffer" ends up with values 0x01 0x01 0x01 0x01
But, if I set up a local buffer in the spi routine I get correct data in that buffer 0x 01 CA DE
Not sure if I am not handling the pointers properly or maybe something is being optimized out. (Though the debug window does not indicate the buffer elements as optimized out.
Originally I was putting spi values directly into "readBuffer" but I could not access the elements in debug window so I created a local array "rxBuf" that holds received values so I could verify they were correct.
Thanks, code below
//Calling C routine
uint32 read32reg(int regFileID,int regOffset)
uint32 regval = 0 ;
int j ;
uint8 buffer ;
dwt_readfromdevice(regFileID,regOffset,4,buffer); // Read 4 bytes (32-bits) register into buffer