Usart giving me headache {solved}

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Making new cables solved the problem :p

 

 

 

 

 

 

 

original post-

Tried changing crystal,reduce wire lengths,and speeds,upto no avail.I also filed down my header pins and tightened my jumping cables.

the code is working .I know that for sure but the usart output is bad somehow...

here's the code-

/*

 * test.cpp

 *

 * Created: 21 Oct,Sat 04:43:10 pm

 *  Author: suraj

 */ 

 

#include <util/delay.h>

#include <avr/io.h>

void delayer(void)

{

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

_delay_ms(1000);

}

void transmitt(unsigned char x)

{

while (!(UCSRA& (1<<UDRE)));

UDR =x;

}

int main(void)

UCSRB =(1<<TXEN);

UCSRC=0x86;

UBRRH=0x03;

UBRRL=0x40;

while(1){

delayer();

transmitt('T');

delayer();

transmitt('E');

delayer();

transmitt('S');

delayer();

transmitt('T');

delayer();

transmitt(' ');

delayer();

}

return(0);

}

The crystal i've tried are 16 mhz with ubrr as above and 11.0952 with ubrr 03ff

 

the output should have been at 600 baud

 

the ftdi reads output as follows-

 

you could see it works but only sometimes

 

As you can see,sometimes it works and someties it doesnt.

 

 

Last Edited: Fri. Jan 26, 2018 - 08:12 AM