PDA

View Full Version : HSERIN2 Problem on 18F23k22



ethobias
- 20th May 2011, 10:24
Hi
I have a problem when trying to use the HSERIN2 command on a 18F23k22. It simply doesnt work. HSERIN works perfectly.
In the code below I am sending one Byte from my PC and would like to read the same byte sent back.
It works on HSERIN but not on HSERIN2!

CM1CON0 = $00 ;Comparator disabled
CM2CON0 = $00 ;Comparator disabled
ANSELA = $00 ;Analog input disabled
ANSELB = $00 ;Analog input disabled
ANSELC = $00 ;Analog input disabled

include "modedefs.bas"
Define OSC 16
Define HSER_RCSTA 90h
Define HSER_BAUD 9600
Define HSER2_RCSTA 90h
Define HSER2_BAUD 9600

Define HSER_CLROERR
Define HSER2_CLROERR
OSCCON = $70 ;FOSC 16MHz
;OSCTUNE = $40 ;PLL Enabled


input portc.7 ;HSERIN1
input portb.7 ;HSERIN2

RXByte1 var Byte
RXByte2 var Byte

mainloop:

HSERIN2 [RXByte1]
Serout Porta.5, T9600, [RXByte1]
Goto mainloop
End

Darrel Taylor
- 20th May 2011, 22:16
Hi ethobias,

Apparently, Microchip has changed the size of the ACCESS bank on this family.
So the HSER2 DEFINEs are not working.
We need to fix that. But in the mean time you can use these statements instead of the DEFINEs.


RCSTA2 = $90 ' Enable serial port & continuous receive
TXSTA2 = $20 ' Enable transmit, BRGH = 0
SPBRG2 = 25 ' 9600 Baud @ 16MHz, 0.16%

mister_e
- 20th May 2011, 23:15
Really? I thought direct register config didn't worked for HSERIN(2).

EDIT: Nevermind, it's a workaround...

Darrel Taylor
- 25th May 2011, 23:48
Well, I started working on a fix for this problem today, and found out there wasn't a problem after all.
Apparently I was looking at the wrong datasheet. :confused:

Testing of the program from post #1 passed on an 18F23K22.

ethobias,
Can you tell me more about your setup?
Are you still having a problem?