I am trying to use usart with avr . But i couldn't send full string. 1 char at time works but char array i cant send.
Please i am open all suggestions . I am just missing something important and couldn't figure out own my own..
Here is my code:
void send_string(const char *str,uint8_t len);
int main(void)
{
USART_Init(207);
adc_init();
//----------------------------------------------------------------------------
const char txt[5]="hello";
PORTB =0b1010000;
USART_Transmit('O');// this part works
USART_Transmit('k');// works
USART_Transmit('!');// works
USART_Transmit(0x0d);//start of new line -> \r
USART_Transmit(0x0a);//new line -> \n
while (1)
{
_delay_ms(500);
sensitivity = adc_read(0);
print_value((char*)'A',(int *)sensitivity); // works. definition is unsigned int sensitivity = 1;
send_string((char *)&txt[0],strlen(txt)); //sounds good does not work :(
send_newln();
defa((char*)&txt[0]);// çalışmıyor
defa((char*)'A');// çalışıyor
}
}
And here are the functions :
void send_string(const char *str,uint8_t len){
while (len--){
USART_Transmit((const char*)*str);
str++;
}
}
void defa(char aa){
for(uint8_t i=0;i<5;i++)
{
USART_Transmit(aa);
}
}