PDA

View Full Version : PIC18F4550 help please



BobEdge
- 27th January 2010, 16:53
I have a problem using a PIC18F4550. Here is my code



DEFINE OSC 20
'rcsta.7 = 0 tried turning usart off but not work
store var byte
number var word
let number = 65531

tx var portc.6
rx var portc.7
led1 var portd.0
led2 var portd.1
low led1
low led2
input rx
high tx

PAUSE 1000
high led1
serout tx, 2, ["Hello"]
pause 500
serout tx, 2, [#number]

start:
serin rx, 2, ["A"], store

pause 1000
low led1
high led2

serout tx, 2, [#store]

pause 1000
low led2
high led1
goto start

end


I am using a terminal program to test serial comms. If I compile for a pic16f871 it works fine, but compiled for a 18f4550 i just get garbage and the pic does not seem to receive anything.

Can anyone tell me what i'm doing wrong please?

Bruce
- 27th January 2010, 19:14
You might have the oscillator config options set to run the CPU at 48MHz.

Try DEFINE OSC 48. If it works, that's the problem.