I have following code:
#define PLL0STAT (*((volatile unsigned short*) 0xE01FC088))
// Function Prototypes
void diaplayInRow1WithPosition(unsigned char* data, unsigned char position);
unsigned char convertLowerNibbleToASCIIValue(unsigned char data);
void func1 (void)
{
unsigned char temp = (unsigned char) PLL0STAT; // Interested in last byte only
temp = convertLowerNibbleToASCIIValue(temp);
diaplayInRow1WithPosition(&temp,15);
}
instead of above code, I thought I will replace the last line with one step and used below statement
diaplayInRow1WithPosition(((unsigned char*)convertLowerNibbleToASCIIValue(temp3)),15);
But the code compiles correctly, but nothing is displayed in LCD. Not able to makeout the reason. Typecasting is done correctly for the pointer I thought. Is there any other issue?
The original code is already fine. Why you are trying to turn it into an unreadable one-liner, I have no idea. You will not gain performance, you will achieve nothing, you only obfuscate the code. As we can see from the need to ask this question: you have made your code unreadable even to yourself. Just leave the code as it was.
The actual bug comes from the strange cast to (unsigned char*)
that you have added.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.