Hi, Am I doing something wrong? The local variable below called 'test_byte' is used to hold return values from function 'ser_buff_read_byte ()'. The value returned is always 0x1D both in the watch window and when I hovered over it! This is not the value returned, in fact I cahnged the code to always return 0x05 and it still did not work!! When I change test_byte to a static it does work??? Help please!! Ian void main (void) { /* Start with 'init' task. */ U8 i; U8 test_byte; ser_buff_write_array (debug_buffer, 3); // debug test write 3 bytes test_byte = ser_buff_read_byte (); // debug test read 1 byte ser_buff_write_array (debug_buffer, 4); // debug test write 4 bytes test_byte = ser_buff_read_byte (); // debug test read 1 byte test_byte = ser_buff_read_byte (); // debug test read 1 byte ser_buff_write_array (debug_buffer, 6); // debug test write 4 bytes while(ser_buff_read_ready ()) // debug test read all byte { test_byte = ser_buff_read_byte (); } ser_buff_write_array (debug_buffer, 2); // debug test write 4 bytes os_sys_init(init); while(1); }
I would guess that test_byte is being optimised away as you never actually use its value. Declaring it as static would prevent this. You code is probably working fine. Try turning off all optimisation, recompile and see what happens.