PDA

View Full Version : Problem accessing keypad on PortB (LabX1, PIC 18F452)



scorpion4377
- 13th January 2009, 16:59
Hey there. I'm trying to use the PIC 18F452 to access a keypad on a LAB X1 board. This is the code that I'm using:

<LCD Configurations>
TRISB = %11110000
PORTB = %11111110
OPTION_REG.7 = 0

If PORTB.4=1 THEN
//The port is low.
ELSE
//The port is high
END IF

END

However, I always get a syntax error for the line:
OPTION_REG.7=0

I looked in the data sheet for this chip, and it does indeed support this register. I'm not exactly sure what is going on. The pins on PORTB are oscillating back and forth between 1 and 0 a little uncontrollably, and I don't think that the rest of the program and its features and interferring at all.

Anybody care to offer some help?
Thank you very much!

Darrel Taylor
- 14th January 2009, 02:23
There are a couple error's in the 452 datasheet. They are just in the notes of the diagrams, so nobody's probably even noticed it.

There really isn't an OPTION_REG in that chip.

The RBPU bit is located at INTCON2.7

hth,

scorpion4377
- 15th January 2009, 03:52
There are a couple error's in the 452 datasheet. They are just in the notes of the diagrams, so nobody's probably even noticed it.

There really isn't an OPTION_REG in that chip.

The RBPU bit is located at INTCON2.7

hth,

Thanks :) You've saved my life....