Cantafford
Member
Hello,
I wrote a code that's supposed to send some serial data via the USART of ATmega328P to a virtual serial port which I emulated in a program called VSP.
The serial port works just fine I have tested it with MATLAB. I have set the baud rates to 9600(both in the code with the given formula in the datasheet and in Proteus simulater under the port's proprieties).
This is the code which is supposed to send the number '8' via the port with a delay of 1 second between transmissions:
This is how I connected it in Proteus:
I can't see character 8 which is supposed to be send on the virtual terminal. Am I doing something wrong in the code or in the interfacing of the virtual terminal with the PIC in Proteus? Please help me identify the issue if possible. Thank you very much.
I wrote a code that's supposed to send some serial data via the USART of ATmega328P to a virtual serial port which I emulated in a program called VSP.
The serial port works just fine I have tested it with MATLAB. I have set the baud rates to 9600(both in the code with the given formula in the datasheet and in Proteus simulater under the port's proprieties).
This is the code which is supposed to send the number '8' via the port with a delay of 1 second between transmissions:
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/delay.h>
#define F_CPU 8000000
#define BAUD 9600
#define BRC ( (F_CPU/16/BAUD) -1) // baud rate calculator
#include <util/delay.h>
int main(void)
{
UBRR0H = (BRC >> 8); // defining the baud rate
UBRR0L = BRC;
UCSR0B = (1 << TXEN0);
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); // number of bits transciever and reciever use
while(1)
{
UDR0 = '8'; // UDR0 is used for transmiting and recieving data(write to it or read from it)
_delay_ms(1000);
}
}
This is how I connected it in Proteus:

I can't see character 8 which is supposed to be send on the virtual terminal. Am I doing something wrong in the code or in the interfacing of the virtual terminal with the PIC in Proteus? Please help me identify the issue if possible. Thank you very much.