The HSEROUT command is probably setting the tris register for the operator to make things easy
No it seems not , I have done a bit more experimenting and the chip works as per the data sheet ie
Setting the SPEN bit of the
RCSTA register enables the EUSART and automatically
configures the TX/CK I/O pin as an output.
seting or clearing the tris bit has no effect on the eusart ,
this int driven background printing demo works just fine when trisc.4 is set or not
clearing bits 4:5 of ANSELC does no good as they are not implemented
correct , that saves a couple of words (don't know how I missed that ) and what you say about APFCON makes sense if it can affect the bootloader
Code:
'****************************************************************
'* Name : PRINT_16_TX_INT.pbp *
'* Author : richard *
'* Notice : *
'* : *
'* Date : *
'* Version : 16f1825 *
'* Notes : *
'* : *
'*
'****************************************************************
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
DEFINE LOADER_USED 1
DEFINE OSC 32
include "dt_ints-14.bas"
include "REENTERPBP.bas"
asm
INT_LIST macro
INT_HANDLER TX_INT , _do_tx, PBP,no
endm
INT_CREATE
ENDASM
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 51 ' 38400 Baud @ 32MHz, 0.16%
SPBRGH = 0
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
prnb var byte[32] bank0
spos var byte bank0
rpos var byte bank0
maxq con 31
HEAD VAR BYTE [70]
I VAR BYTE
J VAR BYTE
K VAR BYTE
PASS VAR WORD
led var latc.0
TRISA=%111111
TRISC=%111110
OSCCON=$f0
ANSELA=0
ANSELC=0
CLEAR
while !OSCSTAT.6
wend
LED=0
INTCON=$C0
ARRAYWRITE head, [ "Ready",9,"%",bin6 trisc,13,10,0]
GOSUB MYPRINT
ARRAYWRITE head, [ "still",9,"%",bin6 trisc,13,10,0]
GOSUB MYPRINT
mainloop:
pause 500
ARRAYWRITE head, [ "still Enable 16 bit baudrate generator ",0]
GOSUB MYPRINT
ARRAYWRITE head, [ "PASS Enable 16 bit baudrate generator",9,#PASS,13,10,0]
GOSUB MYPRINT
PASS=PASS+1
goto mainloop
MYPRINT:
J=0
WHILE HEAD[J]
INTCON=0
I=SPOS+1
K=RPOS
IF ((I)==K) || ((I== MAXQ )&& !K ) THEN
INTCON=$C0
PAUSE 20
led=!led
ELSE
PRNB[SPOS]= HEAD[J]
SPOS=SPOS+1
PIE1.4=1
IF SPOS=MAXQ THEN SPOS=0
J=J+1
ENDIF
INTCON=$C0
WEND
RETURN
:do_tx
IF RPOS == SPOS THEN
PIE1.4=0
ELSE
IF PRNB[RPOS] THEN
TXREG=PRNB[RPOS]
RPOS=RPOS+1
if rpos==maxQ then rpos=0
ENDIF
ENDIF
@ INT_RETURN
Bookmarks