Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

a sample program-USART (need help)

Status
Not open for further replies.

asham

Junior Member level 1
Joined
Jan 24, 2006
Messages
19
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,454
program usart

Hello!! i'm working on the program below...it is supposed to transmit numbers from the hardware to the PC hyperterminal...but it doesnt work due to syntax errors...i hav very poor c language knowledge...it would very helpful if anyone could help me to rectify the errors...there's an error especially in the 'for' statement....thanks....




#include<P18f452.h>

unsigned int i;
void main(void){
TRISC =0b10111111; //RC7(RX) as input & RC6(TX) as output
SPBRG =12; //baud rate =19200
TXSTA =0b00100100; //asynchronous mode, 8-bit data
//transmit enable, high baud rate select bit
RCSTA =0b10010000; //serial port enable,8-bit data
//continuous reception
for(i =30h; i<39h; i++){
//Transmit a byte
while (! TXSTAbits.TRMT); //Is the transmit shift register empty
TXREG = int ; //Write the data byte to the USART
}

while(1);
}
 

Hi

"XREG = int ; //Write the data byte to the USART "

int is a data type
you hade to declare your varable based on this data type at the start of program

like his

int data[9]={00,01,02,......08} //you put the data you need to transmitte in the bracts

and after that in your forr loop
TXREG = data //Write the data byte to the USART

Salam
Hossam Alzomor
 

Thank you...i made the changes you have told me but the syntax errors still exist...the error points to the line 'unsigned int i '...i tried removing this line and compiled the program but then the error moves to the next line...'void(main)void'please help....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top