PDA

View Full Version : serout2 help please...



cpayne
- 3rd March 2006, 14:14
I am pulling my hair out trying to get SEROUT2 to work at 9600. I am using a 18F2220 with a 20MHz crystal. Hserout works fine, I can not get serout2 to work at all. I have tried it on portC.6 with hserout disabled and it still does not work. What am I missing. I am using level converter cables, I know they work because when I exchange them with they both work with the hserout. Hopefully its nothing to do with B.1 being an interrupt, I tried both disabling the interrupts, no luck. I only have B1,B0, B2, and A3 available on this board (was planning on B1 being Tx and B0 as Rx, I am using the hserout for another device, so I need the serout2 to work with it). Any ideas. Many thanks! Charlie



@ __CONFIG _CONFIG1H, _HS_OSC_1H
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG3H, _MCLRE_ON_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L


DEFINE OSC 20 'Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40


PORTA = %00000000 ' output logic at power-up
PORTB = %00000000 ' output logic at power-up
PORTC = %00000000 ' output logic at power-up


' Set up serial UART
define HSER_RCSTA 90H ' Set Receive Status and control register
DEFINE HSER_TXSTA 24H ' set transmit status and control register
DEFINE HSER_BAUD 9615 ' 9615=9600Kbps,19231=19.2Kbps


' Define Analog parameters
ADCON0 = %00010001 '
ADCON1 = %00001011 ' Anolog AN0-AN3, all else digital
ADCON2 = %10000111 ' right justify result
CMCON = %00000111 ' Comparators OFF to allow inputs on pins CMCON = 7


INTCON = %00000000 ' all interrupts OFF


mainloop: ' Main program loop
toggle PORTB.3
hserout ["hserout", 10 ,13]
pause 10
SEROUT2 PORTB.1,16468,["SEROUT2", 10 ,13]
pause 10
SEROUT2 PORTB.1,84,["SEROUT2a", 10 ,13]
pause 250
goto mainloop

Sphere
- 3rd March 2006, 18:08
I think you need to invert the serout2 signal from your pic for it to work with your RS232 to TLL level converter. To prove it just connect your pic directly to your RS232 port on your PC via a 1K resistor. Then try your serout2 command again.

Sphere

cpayne
- 3rd March 2006, 18:44
Thanks for the response. I tried the resitor, no luck. I also tries setting the baud/node number to 84, which should be the same as 16468, except true.

cpayne
- 3rd March 2006, 19:37
Well I tried a new chip, which I was convinced was not the trouble, but it was. Another umpteen hours down the drain. I have no idea what was wrong with the other chip. BTW, you were right with the inversion, mode number should be 84.