Seems that I did not quite understood that PPS thing...
I set the registers as:
RD2PPS=%00011010 for RD2 as UART output
and
RXPPS=%00011011 for RD3 as UART RX input
Hserout does not spiting anything out. Code follows:
Code:
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
__config _CONFIG2, _WRT_OFF & _PPS1WAY_OFF & _ZCD_OFF & _PLLEN_ON & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_OFF
#ENDCONFIG
OSCCON=%11110000
DEFINE OSC 32
LATA = %00000000
LATB = %00000000
LATC = %00000000
LATD = %00000000
LATE = %00000000
TRISA = %00100011
TRISB = %00010011
TRISC = %00000000
TRISD = %00001000
TRISE = %00000000
;*********************************************************************
; ADC Settings
;*********************************************************************
ansela=3
wpua=0
anseld=0
WPUD=0
ODCOND=0
ADCON0=%00000001
ADCON1=%10110000
ADCON2=%00000000
cm1con0=0
cm2con0=0
cm3con0=0
cm4con0=0
cm5con0=0
cm6con0=0
cm7con0=0
cm8con0=0
cm1con1=0
cm2con1=0
cm3con1=0
cm4con1=0
cm5con1=0
cm6con1=0
cm7con1=0
cm8con1=0
cmout=0
;*********************************************************************
' Set LCD Data port
DEFINE LCD_DREG PORTD
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 4
' Set LCD Register Select port
DEFINE LCD_RSREG PORTD
' Set LCD Register Select bit
DEFINE LCD_RSBIT 0
' Set LCD Enable port
DEFINE LCD_EREG PORTD
' Set LCD Enable bit
DEFINE LCD_EBIT 1
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
'DEFINE LCD_COMMANDUS 1500
' Set data delay time in us
'DEFINE LCD_DATAUS 250
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
'DEFINE ADC_CLOCK 3
'************************************************************
' UART Setup
'
DEFINE HSER_RC1STA 90h
DEFINE HSER_TX1STA 24h '9600 baud rate, BRGH=1
DEFINE HSER_BAUD 9600
define HSER_SPBRG 51
DEFINE HSER_CLROERR 1
pause 100
t1con=0
wADC1 var word
DAC1CON0=%10100000 'Enable,right just.,Output enable,Vref
DAC2CON0=%10100000 'Enable,right just.,Output enable,Vref
DAC1REFH=0
DAC1REFL=0
DAC2REFH=0
DAC2REFL=0
DACLD=%00000011
'************* RD2 = UART TX out
RD2PPS=%00011010
'************* RD3 = UART RX input
RXPPS=%00011011
lcdout $fe,$1,"Test"
pause 1500
clear
while 1
adcin 0,wADC1
lcdout $fe,$80,#wADC1," "
toggle latb.5 'LED hertbeat
DAC1REFL=wADC1.lowbyte
DAC1REFH=wADC1.highbyte
DAC2REFL=wADC2.lowbyte
DAC2REFH=wADC2.highbyte
DACLD=%00000011
hserout ["DAC1:",#wADC1,13,10]
pause 500
wend
end
The RD2 pin is the output to the RS-232 driver and RD3 the input from driver. The LED is flashing at the proper rate, so program is looping. But no serial output.
Ioannis
Bookmarks