PDA

View Full Version : serin with pic18f2525



J_norrie
- 21st August 2008, 18:28
Hi everyone hope you can help me.
I have been updating a pic 16f876A program to run on a 18F2525 @8 MHz
header details are
'pic18f2525
DEFINE OSC 8
OSCCON = %11111111

DEFINE LOADER_USED 1 ' Comment out if not using boot-loader
INCLUDE "modedefs.bas"

INTCON2.7 = 0 'enable weak pull-ups on PORTB
but when I run it crashes after about 1 minute every time except when I remove this line

SerIn2 portC.7,16572,600, Loop,[wait("FMS"),dec3 B0]

It seems simple enough but I am just stuck.

the transmit bit works fine

SEROUT2 PortC.6,16572,["LOADX",#volt1,"BATY",#TXBat]

what could it be ?

any suggestions

many thanks again
John

J_norrie
- 22nd August 2008, 10:24
Hi again I hope someone will look at this post and help me with my problem. I have reduced the code to a minimum but it still runs for about a minute then crashes.

Any help most wecome
thanks again John

'pic18f2525
DEFINE OSC 8
OSCCON = %11111111

DEFINE LOADER_USED 1 ' Comment out if not using boot-loader
INCLUDE "modedefs.bas"
TXBAT var word
Volt1 var word
SIGN VAR BYTE
B0 VAR BYTE
B0 =100
SIGN = 1
VOLT1 = 2222
TXBAT = 90
' ----------------------------------------------------------------------------
' MAIN lOOP
' ----------------------------------------------------------------------------

Loop:
GOSUB Transmit
GOSUB SerialInput
GOTO Loop

' ----------------------------------------------------------------------------
' Get Serial Input to serial port 9600 baud inverted
' ----------------------------------------------------------------------------
Serialinput:


SerIn2 portC.7,16468,1000,loop,[wait ("FMS"),dec3 B0]
RETURN

' ----------------------------------------------------------------------------
' Get Load Value and output to serial port 9600 baud inverted WITH - SIGN
' ----------------------------------------------------------------------------
Transmit :

SEROUT2 PortC.6,16468,["SIGN",#SIGN,"LOADX",#volt1,"BATY",#TXBat,"SIGN",#SIGN,"LOADX",#volt1,"BATY",#TXBat,"SIGN",#SIGN,"LOADX",#volt1,"BATY",#TXBat]

RETURN

J_norrie
- 22nd August 2008, 12:48
Hi there,

I have tried the code on a 18f2220 but still the same problem. I tried using DEBUGIN but still the same. Is it to do with the settings of the Hardware UART?, I am not actually sending anything to the pic only sending data at present, but it still fails if I include the serin2 line.

anyone out there with any suggestions . I would be eternally grateful

cheers John

mackrackit
- 23rd August 2008, 05:18
I am just making a wild guess, maybe PORTC.7 should be set LATC.7.
http://www.picbasic.co.uk/forum/showpost.php?p=41657&postcount=9

If I understand this right, LATC will set the pin digital and PORTC is schmitt trigger.

J_norrie
- 25th August 2008, 16:54
thanks Dave, I will give it a try, under pressure at the moment but I will let you know if it worked.

many thanks again
john