This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Read pointer when increasing address does not access data LPC2136

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);

}

}

Parents
  • Your indentation is a bit messed-up.

    void static commandList(const uint8_t *addr) {
    
      uint8_t numCommands, numArgs;
      uint16_t ms;
    
      numCommands = *(addr++);           // This value is recieved correct
    
      while(numCommands--) {             // For each command...
        writecommand( *(addr++) );       //   Read, issue the pointer not increment correctly
        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();
      }
    }
    

    "the pointer does not increase"

    But does writecommand() actually receive the correct value?

    And does numArgs get set to the correct value?

Reply
  • Your indentation is a bit messed-up.

    void static commandList(const uint8_t *addr) {
    
      uint8_t numCommands, numArgs;
      uint16_t ms;
    
      numCommands = *(addr++);           // This value is recieved correct
    
      while(numCommands--) {             // For each command...
        writecommand( *(addr++) );       //   Read, issue the pointer not increment correctly
        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();
      }
    }
    

    "the pointer does not increase"

    But does writecommand() actually receive the correct value?

    And does numArgs get set to the correct value?

Children
No data