PDA

View Full Version : PIC18F46K22 config issue



LGabrielson
- 14th September 2012, 00:21
Hi folks,

Im trying to use a PIC18F46K22 for the first time, and am having a little trouble with the config for PORTD. I am using D.2 & D.3 as DEBUG pins, and D.5 as a LED indicator. The first thing I'm trying to do is turn off the LED by setting D.5 high. So far, so good. Then I try to send something out the DEBUG port D.2. The LED promptly turns right back on again.

The only PORT config I have is:

ASM
;PORT D
CLRF PORTD
MOVLW 00001000b ;SET PIN DIRECTIONS
MOVWF TRISD
ENDASM

and my DEBUG setup looks like this:

'DEBUG PORT
DEFINE DEBUG_REG PORTD 'DEBUG PINS ARE IN PORTD
DEFINE DEBUG_BIT 2 'TRANSMIT DEBUG PIN IS PORTD.2
DEFINE DEBUGIN_BIT 3 'RECEIVE DEBUG PIN IS PORTD.3
DEFINE DEBUG_BAUD 115200 'DEBUG PORT IS 115200 BAUD.
DEFINE DEBUG_MODE 0 'INVERTED OUTPUT

Can someone with more experience with these configs tell me why my DEBUG command might be interacting with my LED?

Thanks much,
Len

HenrikOlsson
- 14th September 2012, 06:02
Hi,
Don't think it has anything to do with your CONFIG bits, it sounds more like a RMW issue to me. To verify if that's the case either insert a PAUSE between the setting the output and the DEBUG statement or control the LED by writing to LATD instead of PORTD.

/Henrik.

LGabrielson
- 29th September 2012, 03:20
Datasheet Page 153 [10.7]