I'm blocked because of an issue that is causing a lot of time loss. I've created a function to get the LSB and another one to get the MSB.
char get_LSB (int n){
unsigned char lsb = (unsigned)n & 0xFF; // mask the lower 8 bits
return lsb;
}
char get_MSB (int n){
unsigned char msb = ((unsigned)n >> 8 );// shift the higher 8 bits
return msb;
}
It doesn't work as when I call the function get_LSB or get_MSB I get a result different from what I expected. Let's check the following example:
void main() {
TRSISC = 0x00;
PORTC = get_LSB(100);// function should return 100 but returns 68
Delay_ms(5000);
PORTC = get_MSB(360); // should return 1 but returns 0
}
get_MSB(360)
should be returning0x68
- probably the result that you believe it is returning forget_LSB(100)
. Please tell us how do you read out the results. \$\endgroup\$