Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
Our following program example illustrates use of hardware serial communication. Data received from PC is stored into 
variable dat and sent back to PC as confirmation of successful transfer. Thus, it is easy to check if communication works 
properly. Transfer format is 8N1 and transfer rate is 2400 baud.
program USART_Echo
dim dat as byte
main:
USART_Init(2400) ' Initialize USART module
while true
 if USART_Data_Ready = 1 then ' If data is received
 dat = USART_Read ' Read the received data
 USART_Write(dat) ' Send data via USART
 end if
wend
end.
In order to establish the communication, PC must have a communication software installed. One such communication 
terminal is part of mikroBasic IDE. It can be accessed by clicking Tools > Terminal from the drop-down menu. Terminal 
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/06.htm (11 sur 12)05/11/2004 02:26:25










