mzannerni
Newbie level 3
- Joined
- Mar 19, 2014
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 29
Hello guys,
I used to program with bascom language and now i just start using the C language,
I wrote a code to send data using USART,and i tried to simulate it on proteus 8 virtual terminal but it is not working ..
Could you figure out my mistake !
i will post my code here :
I adjest the proteus terminal to the same settings,same baud ! :roll:
is there any better program to simulate my program ?!
I used to program with bascom language and now i just start using the C language,
I wrote a code to send data using USART,and i tried to simulate it on proteus 8 virtual terminal but it is not working ..
Could you figure out my mistake !
i will post my code here :
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include <avr/io.h> #include <stdio.h> unsigned char data; int delay; // function to send data void USART_TRANS (unsigned char data) { while (!( UCSRA & (1<<UDRE))); // wait while register is free UDR = data; // load data in the register } // function to receive data unsigned char USART_REC (void) { while(!(UCSRA) & (1<<RXC)); // wait while data is being received return UDR; // return 8-bit data } int main(void) { UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM); UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8); UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL); UBRRH=0x00; UBRRL=0X33; //BAUD 9600 AND CRYSTAL 8.000.000 data="Hello !"; while(1) { USART_TRANS(data); for (delay=0;delay=1000;delay++) ; } }
I adjest the proteus terminal to the same settings,same baud ! :roll:
is there any better program to simulate my program ?!
Last edited by a moderator: