Hello,
I'm trying to use CANRAM for logging purposes (CAN-hardware is not used). So I wrote a small test-program to try this.
I'm wondering why everything works if only AHBSRAM0+1 is used, but the code don't even start if the line (35) where CANRAM is accessed is uncommented?
#include "mbed.h"
#define BYTES_DISPLAY_PER_ROW 16
__attribute((section("AHBSRAM0"))) char mem1[1];
__attribute((section("AHBSRAM1"))) char mem2[1];
__attribute((section("CANRAM"))) char mem3[1];
DigitalOut myled(LED1);
int DispHex(char* data,int count)
{
printf("\r\n\r\n## Memory-dump at 0x%4.4x ##\r\n",(int)data);
int width=BYTES_DISPLAY_PER_ROW;
for (int i=0; i<count; i++) {
if (width==BYTES_DISPLAY_PER_ROW) {
printf("\r\n0x%4.4X: %2.2X ",data+i,(char*)data[i]);
width=0;
} else {
printf("%2.2X ",(char*)data[i]);
}
width++;
}
return(0);
}
int main()
{
printf("\n\rAHBSRAM0:\n\r");
DispHex(&mem1[0],512);
printf("\n\rAHBSRAM1:\n\r");
DispHex(&mem2[0],512);
printf("\n\rCANRAM:\n\r");
// DispHex(&mem3[0],512); // works only if commented out
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Must the can-controller be powered on to use its ram (and is it powered off if mbed is started without using can-related functions) or why does mbed hang?
BTW: I'm trying this to collect debug-info which is beeing sent by e-mail if there's a watchdog-reset, for example. I guess this ram-area isn't 0-initialized if CAN-hardware isn't used - that was the reason for this test-code. If it' initialized anyway my code would be useless unless removing initialization in the mbed-source...
Any help is welcome...
Thanks,
Michael
Hello,
I'm trying to use CANRAM for logging purposes (CAN-hardware is not used). So I wrote a small test-program to try this. I'm wondering why everything works if only AHBSRAM0+1 is used, but the code don't even start if the line (35) where CANRAM is accessed is uncommented?
#include "mbed.h" #define BYTES_DISPLAY_PER_ROW 16 __attribute((section("AHBSRAM0"))) char mem1[1]; __attribute((section("AHBSRAM1"))) char mem2[1]; __attribute((section("CANRAM"))) char mem3[1]; DigitalOut myled(LED1); int DispHex(char* data,int count) { printf("\r\n\r\n## Memory-dump at 0x%4.4x ##\r\n",(int)data); int width=BYTES_DISPLAY_PER_ROW; for (int i=0; i<count; i++) { if (width==BYTES_DISPLAY_PER_ROW) { printf("\r\n0x%4.4X: %2.2X ",data+i,(char*)data[i]); width=0; } else { printf("%2.2X ",(char*)data[i]); } width++; } return(0); } int main() { printf("\n\rAHBSRAM0:\n\r"); DispHex(&mem1[0],512); printf("\n\rAHBSRAM1:\n\r"); DispHex(&mem2[0],512); printf("\n\rCANRAM:\n\r"); // DispHex(&mem3[0],512); // works only if commented out while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } }Must the can-controller be powered on to use its ram (and is it powered off if mbed is started without using can-related functions) or why does mbed hang?
BTW: I'm trying this to collect debug-info which is beeing sent by e-mail if there's a watchdog-reset, for example. I guess this ram-area isn't 0-initialized if CAN-hardware isn't used - that was the reason for this test-code. If it' initialized anyway my code would be useless unless removing initialization in the mbed-source...
Any help is welcome...
Thanks, Michael