asham
Junior Member level 1
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);
}
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);
}