I know this is probably a basic question about storing of variables in memory but...
First, if I take a 16bit integer, split it into 2 bytes, then place these into adjacent elements in a char array.
Then, if I call a function expecting to be passed a 16bit integer and give it an element of the char array.
Will it copy the contents of the array element specified and then copy the next one automatically too?
Note: I might have reversed MSB and LSB below?
Is this bad programming?
/* Variables/Functions Used */ char testFailRef [16]; unsigned int testIndex; unsigned int testCycleCount; LCD_senduwasciidec4bit(unsigned int data); //This function takes a 16 bit integer as input, then outputs this number on the LCD display (i.e. as seperate 'chars') //It will only output the correct number of digits based on the size of the variable //i.e. If data = 1500, it will send "1""5""0""0" to the LCD as 4 chars. /* Write to array */ resultBuffer.testFailRef[0] = testIndex; resultBuffer.testFailRef[1] = (ubyte)(testCycleCount & 0xff); //LSB resultBuffer.testFailRef[2] = (ubyte)((testCycleCount >> 8)& 0xff); //MSB /*Read from array */ //Option #1 LCD_senduwasciidec4bit(((uword)resultBuffer.testFailRef[1]) + ((uword)resultBuffer.testFailRef[2]<<8)); //Option #2 LCD_senduwasciidec4bit(resultBuffer.testFailRef[1]);
View all questions in Keil forum