Guys, I don't know what's going on, but I am playing around with the 12f1822. I've come to a point that it is driving me absolutely mad. I was hoping someone might have some insight into what is going on.
Here's the code.
Line Address Opcode Label Disassembly
1 000 2805 GOTO 0x5
2 001 0000 NOP
3 002 0000 NOP
4 003 0000 NOP
5 004 2805 GOTO 0x5
6 005 0000 NOP
7 006 0020 MOVLB 0
8 007 198C BTFSC PORTA, 0x3
9 008 280D GOTO 0xd
10 009 0022 MOVLB 0x2
11 00A 168C BSF LATA, 0x5
12 00B 0021 MOVLB 0x1
13 00C 128C BCF TRISA, 0x5
14 00D 280D GOTO 0xd
At this point I've stripped out all the "useful" code to try to figure out why it is working this way.
I have a weak pull up resistor going from Pin 1 to Pin 4. I then have a tactile switch going from Pin 4 to Pin 8.
So with the tactile switch open, PORTA,3 should read 1 and with it closed it should read 0.
But it seems to be working the opposite. I have a LED wired to pin 5 that turns on when the tactile switch is NOT pressed and stays off when it is.
It SEEMS like somehow that PORTA is reading backwards, but I know that isn't possible. I know something else has to be going on. I'm just not sure what.
Edit:
I rewrote the code in C and got the same results.
#include <xc.h>
void main()
{
if(PORTAbits.RA3 == 0)
{
LATAbits.LATA5 = 1;
TRISAbits.TRISA5 = 0;
}
while(1);
}
I'm so confused. Is it possible that this is related to my configuration bits?
UPDATE:
Apparently I'm a noob. I had MCLR enabled in my configuration bits. Well, that's 3 days of my life that I'm never getting back.
Thanks, Hazer. Yeah,...in retrospect that may not have been the best way to troubleshoot.
@Anonamous, Lol! It usually takes 8 years of school to provide THAT KIND of help.