However RA5 flips fine on Timer 1 interrupt but RA4 there is no change. ie RA5 filps after every 100 interrupts but RA4 always shows 0V on a multimeter.
I use the following code to enable interrupts
Code:
PEIE = 1; // Enable Peripheral Interrupts
GIE = 1; // Enable Global interrupts
I am using the follwing initialize sequence:
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
& UNPROTECT & BORDIS & IESODIS & FCMDIS); using the PICC compiler.
hi,
RA4 is an open drain output, it requires an external pullup resistor when used as an output.
EDIT: checking the 16F688 d/s shows that RA4 on this model has a programmable 'pullup'.
Have you programmed the pullup.?
hi,
RA4 is an open drain output, it requires an external pullup resistor when used as an output.
EDIT: checking the 16F688 d/s shows that RA4 on this model has a programmable 'pullup'.
Have you programmed the pullup.?
I am not sure how to program the pullup. Should I use the ANSEL register to program the pullup.
Per the datasheet I was not able to locate pullup specific information. What i found is-> "TRISA5 and TRISA4 bits are set when the Timer1 oscillator is enabled. RA5 and RA4 read as ‘0’ and TRISA5 and TRISA4 bits read as ‘1’."??
Where in the 16F688 data sheet does it mention RA4 is open drain/collector?
The port pin RA4 is stated in the datasheet as "General purpose I/O & CLK output" and the block diagram of RA4 looks like RA5 in my DS41203B datasheet.
The default on reset is that the IO pins are set for Analog input by ANSEL. Now, while TRISA will set them for output, when you read the pin it is still in analog input mode which will mess up any read-modify-write operations which your C code may or may not generate for the RA4=1 statement. So try setting it like this:
ANSEL = 0;
From the 16F688 datasheet:
The state of the ANSEL bits has no affect on digital
output functions. A pin with TRIS clear and ANSEL set
will still operate as a digital output, but the Input mode
will be analog. This can cause unexpected behavior
when executing read-modify-write instructions on the
affected port.
The default reset state for CMCON0 is 0 which leaves the comparators in reset, but the pins in analog mode. RA4 doesn't have comparator assigned to it, but to save you further IO grief, try setting it like this:
CMCON0 = 0x07;
I don't think the pin is open drain due to the fact that it can double as the OSC2/CLKOUT pin as well. But if the above doesn't work, try an external 470Ω pull up resistor.