We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Okay, I'm trying to pass a pointer to a char buffer to a function. It works fine in the Keil simulator/debugger, but not on the target hardware. // Variable Declaration #define MAX_RX_SIZE 100 static char xdata cmdBuffer[MAX_RX_SIZE]; // Calling function void CallingFunc(void) { // cmdBuffer is read in from serial // port and contains "EF" printf("\r\nP2_CMDFOUND\r\n"); printf(cmdBuffer); if (!process_EraseFlash(cmdBuffer)) { printf("\r\nP2_INVALARG\r\n"); printf(cmdBuffer); printf("\n**invalid arguments"); } else { printf("\r\nFcn Success\r\n"); printf(cmdBuffer); } } // Called Function BYTE process_EraseFlash(char *cmdBuffer) reentrant { printf("\r\nP2_CMDEF\r\n"); printf(cmdBuffer); if (strcmp(cmdBuffer, "EF")) return FALSE; if (flash_ChipErase()) printf("\r\nOK"); else printf("\r\n**Error>\r\n"); return TRUE; } Okay, here's the output from the simulator: P2_CMDFOUND EF P2_CMDEF EF OK Fcn Success EF And here's the output from the target hardware: P2_CMDFOUND EF P2_CMDEF P2_INVALARG EF **invalid arguments Looks like the pointer is not being passed to the process function properly, as the process function thinks the buffer is empty. Any ideas? I'm stuck here. Thanks, Chris Beattie
Okay, I'm trying to pass a pointer to a char buffer to a function. It works fine in the Keil simulator/debugger, but not on the target hardware.
// Variable Declaration #define MAX_RX_SIZE 100 static char xdata cmdBuffer[MAX_RX_SIZE]; // Calling function void CallingFunc(void) { // cmdBuffer is read in from serial // port and contains "EF" printf("\r\nP2_CMDFOUND\r\n"); printf(cmdBuffer); if (!process_EraseFlash(cmdBuffer)) { printf("\r\nP2_INVALARG\r\n"); printf(cmdBuffer); printf("\n**invalid arguments"); } else { printf("\r\nFcn Success\r\n"); printf(cmdBuffer); } } // Called Function BYTE process_EraseFlash(char *cmdBuffer) reentrant { printf("\r\nP2_CMDEF\r\n"); printf(cmdBuffer); if (strcmp(cmdBuffer, "EF")) return FALSE; if (flash_ChipErase()) printf("\r\nOK"); else printf("\r\n**Error>\r\n"); return TRUE; }
P2_CMDFOUND EF P2_CMDEF EF OK Fcn Success EF
P2_CMDFOUND EF P2_CMDEF P2_INVALARG EF **invalid arguments
Hi Erik,<br> <br> well, just looked it up again... you can sure use the internal clock too. I just remembered an old application of mine, where I used a variable external clock to meassure the length of something moving through a light barrier. The external clock was relative to the speed of the movement. So I was not sure, if the c51 would be able to use the internal clock for the capture mode... just too long ago :))<br> <br> Take care<br> Sven