Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

hi please correct this coding

Status
Not open for further replies.

hanukaran

New Member
is that i have to define the register..coz if i not define its show error that undefined..i'm using codevision avr .anybody help me please

#include <mega32.h>
#include <delay.h>

#define red_1 PORTA.0
#define yellow_1 PORTA.1
#define green_1 PORTA.2




#define UCSZ0 1
#define UCSZ1 2
#define USBS 3
#define URSEL 7
#define UDRE 5
#define TXC 6
#define RXC 7
#define TXEN 3
#define RXEN 4




void USART_Init(unsigned short int F_CPU_MHz, unsigned short int Baud_Rate)
{
F_CPU_MHz = 8;
Baud_Rate = 9600 ;
UCSRB = 0x00; // Disable while setting baud rate
UCSRA = 0x00; // Disable USART flags
UCSRC = (1<<USBS)|(1<<UCSZ1)|(1<<UCSZ0); // 8-Bit data, 1-Bit Stop
UBRRL = ((F_CPU_MHz*1000000)/Baud_Rate/16)-1; // Set Baud Rate Lo - Asynch Normal Mode
UBRRH = 0x00; // Set Baud Rate Hi
UCSRB = (1<<RXEN)|(1<<TXEN); // Enable USART TX and RX
}
void Send_Byte(char data)
{

while ((UCSRA & (1<<UDRE)) == 0);
UDR = data;
}


char Receive_Byte(void)
{

while((UCSRA&(1<<RXC)) == 0);
return UDR;
}




void main(void){
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x03;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0xFF;

while (1)
{
red_1=0;
green_1=1;
delay_ms(1500);
green_1=0;
yellow_1=1;
delay_ms(1500);
yellow_1=0;
red_1=1;
delay_ms(1500);
};


while(1)
{

if (yellow_1==0)
{
red_1=1;
Send_Byte('R');
} }



}
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top