Hey,
I've been working on some code to transmit a single character. I've set up a small circuit using the PicKit 2 programmer and a UM232R USB to Serial converter module and a 16F628 Pic.
I've tested the UM232R by looping back its TX and RX pins to check that it's operating and all is fine. I've also used the UART Tool in the PicKit 2 software to try and receive the transmitted character from the Pic but had no success with this either. I've also wrote and loaded a small program to turn on some LEDs with the same configuration settings that confirms the Pic is operating correctly (this is also verified in the PicKit 2 software).
After ruling out the hardware I've been trying to debug the code but have now totally drawn a blank. Could anyone have a quick check over to see if there is an obvious error that needs correcting? The code has been pasted here.
Thanks for any help that anyone can provide!
Pete
I've been working on some code to transmit a single character. I've set up a small circuit using the PicKit 2 programmer and a UM232R USB to Serial converter module and a 16F628 Pic.
I've tested the UM232R by looping back its TX and RX pins to check that it's operating and all is fine. I've also used the UART Tool in the PicKit 2 software to try and receive the transmitted character from the Pic but had no success with this either. I've also wrote and loaded a small program to turn on some LEDs with the same configuration settings that confirms the Pic is operating correctly (this is also verified in the PicKit 2 software).
After ruling out the hardware I've been trying to debug the code but have now totally drawn a blank. Could anyone have a quick check over to see if there is an obvious error that needs correcting? The code has been pasted here.
Thanks for any help that anyone can provide!
Pete
Code:
LIST P=16F628 ;16F628 PROCESSOR
#include <P16F628.INC> ;Include header file
__config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON & _MCLRE_ON
CBLOCK 0x20 ;Declare variable addresses starting at 0x20
dataL
ENDC
ORG 0x000
movlw 0x07 ;Turn comparators off
movwf CMCON
; INITIALISE PORTS
bsf STATUS,RP0 ;Select Bank 1
movlw b'00000100' ;Set RB2 to Tx
movwf TRISB
; CONFIGURE BAUD RATE AND TX REGISTER
movlw 0x19 ;9600 baud
movwf SPBRG
movlw b'00100100' ;Transmit enable, high baud rate
movwf TXSTA
bcf STATUS,RP0 ;Select Bank 0
; MAIN PROGRAM
loop call message
goto loop
; MESSAGE SUB-ROUTINE
message movlw 'Y'
movwf TXREG
return
END