PDA

View Full Version : Serial Communication again but easier i think ;)



Armando Herjim
- 21st June 2006, 03:50
Hello again. Look I have another little problem with my serial communication. I just find the solution to my last problem but now, now it sends nothing or just sends crap. This is what I´m doing. I´m working with a Pic 18F4550 and I have it working with a 10 Mhz Xtal and with the pll postcaler so internally it is running at 40 Mhz. What I want to do is to transmit and recieve at a baudrate of 115200 but when I try to it sends nothing, or sometime it sends trash...
OSCCON = $50 'Set OSCILLATOR CONTROL REGISTER TO 1101 0000
'Oscillator control register para seleccionar el modo de clock

DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 115200
;DEFINE HSER_SPBRG 25 --------> is this correct? i put it like a comment

DEFINE OSC 40 -------> is this correct?

and can anybody please tell me if the next part of code works fine?:

high portb.7
hserout ["Armando 130, 256 epacion a ·$/&$&( ;", 10, 13]
pause 500
low portb.7
;----------------------
pause 500
;----------------------
high portb.7
hserin [str da\10]
low portb.7
;-----------------------
hserout[10,13]
hserout[str da\10 ,10, 13]

my .inc file is looks like this:

;************************************************* ***************
;* 18F4550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F4550, r = dec, w = -311, f = inhx32
INCLUDE "P18F4550.INC" ; MPASM Header
CONFIG USBDIV = 1
CONFIG CPUDIV = OSC3_PLL4
CONFIG PLLDIV = 1
CONFIG IESO = ON
CONFIG FCMEM = OFF
CONFIG FOSC = HSPLL_HS
CONFIG PBADEN = OFF

;__CONFIG _CONFIG1L, _PLLDIV_3_1L & _CPUDIV_OSC1_PLL2_1L
;__CONFIG _CONFIG1H, _FOSC_XT_XT_1H
;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
;__CONFIG _CONFIG3H, _PBADEN_OFF_3H
;__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32

-----------------------------------------------------------------------------------------------------------------------------------------------------

Well, that´s it! Again I hope somebody could please help me! What the heck am I doing wrong?!?!?

thanks to all of you

Armando Herjim