
Originally Posted by
mackrackit
Below are the setting for 9600 baud at 16MHz
Code:
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 25 ' 9600 Baud @ 0.16%
You have the ones in your code commented out.
Run this code and type numbers at the keyboard.
Code:
ASM ; 18F2550/4550, 8mhz crystal
__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
DEFINE OSC 16
ADCON1 = 15 ' All I/O pins digital
PORTB.6 = 0 ' Turn off the LEDs PORTB.7 = 0
X VAR BYTE
START:
RCSTA.4 = 0 : RCSTA.4 = 1
RCSTA=$90:TXSTA=$20:SPBRG=25
HSERIN [DEC X]
HSEROUT [DEC X,$d,$a]
GOTO START
Mackrackit, I created a .pbp file from your above code with a slight modification where I inserted a LED turn on just after the HSERIN and just after the HSEROUT statements. See the code below. Then when running the code and typing characters on the keyboard I do not see these respective lights come on in the EasyPic6. This says the HSERIN and the HSEROUT statements are never executing when the code is running and the PC terminal is connected. This implies a hardware failure somwhere in the EasyPic6 serial interface circuitry....do you agree???
Code:
ASM ; 18F2550/4550, 8mhz crystal
__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
DEFINE OSC 16
TRISB = %00001111 ' Set PORTB.4,5,6,7 to outputs as test LEDs
ADCON1 = 15 ' All I/O pins digital
PORTB.6 = 0 ' Turn off the LEDs
PORTB.7 = 0
X VAR BYTE
START:
RCSTA.4 = 0 : RCSTA.4 = 1
RCSTA=$90:TXSTA=$20:SPBRG=25
HSERIN [DEC X]
PORTB.6 = 1 ' Turn on PortB.6 LED if this statement is executed
' as test of receiving a character
HSEROUT [DEC X,$d,$a]
PORTB.7 =1 ' Turn on PortB.7 LED if this statement is executed
' as test of HSEROUT having sent a character
GOTO START
Bookmarks