PDA

View Full Version : Serout2 at 9600 problem



nuno106
- 29th August 2012, 15:51
Hello,

My code is:

;##################################
DEFINE OSC 8
OSCCON = %01110000

ASM
__CONFIG _CONFIG1L, _PLLDIV_2_1L ; Divide by 2 (8 MHz oscillator input)
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L
ENDASM

include "modedefs.bas"
ADCON1 = 15 ' Set all I/Os to Digital
CMCON = 7 ' Disable Comparators

Main:
pause 100
high Led_1
Serout2 Portc.1,84,["Test",10,12]
pause 200
Goto Main
End
;##################################

I'm using a 8MHz Cristal, and define it at the begining of the program. The 84 at serout command is for 9600, but it sends the text at 2400...

Anyone understand why?

Thanks,
Nuno

mackrackit
- 29th August 2012, 16:17
You did not give the chip you are using.
But this may give you a clue.
http://www.picbasic.co.uk/forum/showthread.php?t=5806&p=68359#post68359

Fujimanme
- 4th September 2012, 05:58
Firstly, use TOGGLE Led_1.... as your LED will never go off

Second, how are you verifying the rate is 2400? What terminal program are you using?

nuno106
- 4th September 2012, 09:49
Hello,

Thank for your answers.

I'm using a 18F2550. To verify the baud rate, i'm using the hyperterminal from windows.

I think that my problem is in definition of the Pic, I not understand why we need to define the oscilator 2 times:

DEFINE OSC 8
__CONFIG _CONFIG1L, _PLLDIV_2_1L ; Divide by 2 (8 MHz oscillator input)

Thanks,
Nuno

mackrackit
- 4th September 2012, 13:33
Try this


@ __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H

DEFINE OSC 48