Hi, I have to transmit an unsigned long as four bytes, so I split them up and join them again, but with the folowing example code, I get overflow at long_counter>32767 - can any of you give me a clue how to do it right?
unsigned
char i; unsigned long long_counter; unsigned char char_counter[4];
void main(void) { unsigned char len; unsigned char lcd_buf[16];
OSCCONbits.SCS = 0x0; // System Clock Select bits = External oscillator OSCCONbits.IRCF = 0x7; // Internal Oscillator Frequency Select bits 8 MHz (INTOSC drives clock directly)
lcd_init(); while (1) { for (long_counter = 0; long_counter < 0xffff0000; long_counter += 50) { // split long_counter to four unsigned char's for (i = 0; i < 4; i++) { char_counter[i] = (long_counter & (0xff
// convert them to unsigned int again long_counter = char_counter[0] | (char_counter[1]