PDA

View Full Version : First time with 18F pic...



gabrielg74
- 9th December 2005, 05:39
Hello,

I ran out of space when writing a program for the PIC16C66 (original was in assembler, but wanted to port it to PBP for ease of updating). So I got a PIC18F2610, after modifying the necessary assembler routines, configuration registers, etc. The original program that was running perfectly in the 16C66 compiled fine, but didn't work at all in the 18F2610.
So being a first timer with a 18F pic I decided to start from the beginning and try the led flasher program, no problem there, so the pic is fine so far. But then I tried this small routine of the program, really straightforward and with no fancy coding:

'Port Asignment
'PortA.3 Serial output to LCD
'PortA.5 MCLR for LCD
'PortC.2 Led

DEFINE OSC 20
DEFINE NO_CLRWDT 1

Init_LCD:
HIGH PortA.3 'Initial state of serial line
HIGH PortA.5 'Enable LCD
PAUSE 100 'Wait for LCD to start
SEROUT2 PortA.3,84,["U"] 'Set transmision speed
PAUSE 60
SEROUT2 PortA.3,84,[$01] 'Clear LCD
PAUSE 5
SEROUT2 PortA.3,84,[$0C] 'Turn off insertion point
PAUSE 5
SEROUT2 PortA.3,84,["Printer Control",$00,$40,"v 3.0"] 'Display message
PAUSE 4000 'Wait 4 secs.
SEROUT2 PortA.3,84,[$01] 'Clear LCD

Loop:
TOGGLE PortC.2 'Flash LED when finished
PAUSE 1000
GOTO Loop

END

As you can see there is not much about it, and this same code works perfectly on the 16C66. I tried different configurations of the processor but no luck. The only thing that works fine is the led flashing at the end.
The serial output for the LCD goes to another PIC board that interfaces an LCD thru a serial port, this has been used in many different projects without a problem, just in case you are wondering.

If you can share any info on how to make this PIC work I will really appreciate it.

Thanks in advance,

Gabriel

Peder
- 9th December 2005, 06:16
Has PortA been changed to digital outputs?

gabrielg74
- 9th December 2005, 07:04
He, he, he...

Got me!!!

I've forgotten completely about the Analog capabilities of this device, as I was never using them...

Thanks a lot...

Gabriel