your help please, this pointer initially takes the first value extracted from the address, but when I try to increase the pointer to access the next value it does not do anything.(ARM7TDMI LPC2136):
void static commandList(const uint8_t *addr) {
uint8_t numCommands, numArgs; uint16_t ms;
numCommands = *(addr++); // Number of commands to follow while(numCommands--) { // For each command... writecommand((uint8_t) *(addr++)); // Read, issue command numArgs = *(addr++); // Number of args to follow ms = numArgs & DELAY; // If hibit set, delay follows args numArgs &= ~DELAY; // Mask out delay bit while(numArgs--) { // For each argument... writedata(*(addr++)); // Read, issue argument }
Delay(ms);
}
Instrument your code with printf() to understand what happening in the loop and in the writedata() function.
Variables may be held in registers, not memory
But does writecommand() actually receive the correct value?
As I said earlier the instruction * (addr ++) is not working.
No, it is not taking the values. will take the value zero at all times.
And does numArgs get set to the correct value?
I have run the program step by step but I did not identify the reason of the problem. if you are interested I can take screenshots with the assembler code.
Thanks.
void static commandList( const uint8_t *addr )
Is that 'const' in the right place ... ? Yes, it is.
This code if I compile it for the arm cortex of texas Tiva C tm4c123g. works correctly. but when I carry the code and compile for the ARM7tdmi lpc2136 it gives this problem with the pointer. and with the simulation of delays.
Compiled on a PC, generates sequences you're not handling properly
# 15 CMD 11 (17) DELAY CMD 96 (150) DAT 80 . DAT FF . DAT 33 3 DAT 03 . DAT 01 . DAT 2C , DAT 2D - DAT 44 D DAT 03 . DAT 01 . DAT 2C , DAT 2D - DAT 55 U
Took liberties with the missing defines, but still looks broken to me.
>>if you are interested I can take screenshots with the assembler code. A listing file, or FromELF disassembly might be better, but the underlying logic is flawed. Instrument the code, understand what it actually does. Compiler doing what you tell it to do.
after doing several tests remove the "static" modifier from the function and leave it as a normal call. after this I am capturing the values correctly from the pointer.
I must clarify that this function belongs to the library of the TFT LCD 128x160 with the ST7735 driver.
Thank you (Andrew Neil) and the others for your comments!!