c - AVR gcc, weird array behaviour -
it's first time see this. i'm starting suspect it's hardware fault. whenever try send contents of array "test" , array larger 4 elements or initialize elements in declaration contains 0xff instead of values try initialise with.
this works fine. when read values array in while(sending them lcd , uart) both readouts consistent test values:
uint8_t i=0; uint8_t test[4] = {1,2,3,4}; while(i<5){ glcd_writedata(test[i]); usart_transmit(test[i]); i++; }
this doesn't, returns 0xff instead of test[i] value:
uint8_t i=0; uint8_t test[5] = {1,2,3,4,5}; while(i<5){ glcd_writedata(test[i]); usart_transmit(test[i]); i++; }
but works! returns proper values
uint8_t i=0; uint8_t test[6] = {1,2,3,4,5}; while(i<5){ glcd_writedata(test[i]); usart_transmit(test[i]); i++; }
this works:
uint8_t i=0; uint8_t test[5]; test[0]=1; test[1]=2; test[2]=3; test[3]=4; test[4]=5; while(i<5){ glcd_writedata(test[i]); usart_transmit(test[i]); i++; }
it works fine when compiled on linux
i swapped out mcu different 1 , works way should. must hardware problem
in first example going out of bounds of array test[4]. running while 5 times, when array has 4 items length.
Comments
Post a Comment