PDA

View Full Version : Setup baudrate on hardware uart on 18F4520



Pedro Pinto
- 25th August 2010, 00:07
Hello

With this code i init the uart, suposed with the baudrate 2400, but on the Microcode communication Tool it works correctly only if i select 9600.
Anyone know what is the problem?
Thanks for explanation
Best regards
Pedro

DEFINE OSC 16
INCLUDE "modedefs.bas"
INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts

ASM
INT_LIST macro
INT_Handler RX_INT, _IntRx, PBP, yes
endm
INT_CREATE
ENDASM
@ INT_ENABLE RX_INT

' Initialize USART
TRISC = %10111111 ' Set TX (PortC.6) to out, rest in
SPBRG = 25 ' Set baud rate to 2400
RCSTA = %10010000 ' Enable serial port and continuous receive
TXSTA = %00100000 ' Enable transmit and asynchronous mode

Pedro Pinto
- 25th August 2010, 00:31
Hello again

Problem is solved reading a old post and thanks PicMultiCalc program

Best regards
Pedro