Author Topic: I'm going to cry if I don't get some help...  (Read 2055 times)

Offline SethMods

  • Registered BST
  • King of the Wii-tards
  • *
  • Posts: 189
  • Post quality +17/-1
  • Gender: Male
  • Acidmods User
I'm going to cry if I don't get some help...
« on: July 27, 2012, 02:50:56 PM »
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             

 
Code: [Select]
    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.
Code: [Select]
#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.
« Last Edit: July 28, 2012, 12:41:08 PM by SethMods »

Offline Hazer

  • x4675636B4E7574
  • Acidmods Alumni
  • Acid Modder
  • *
  • Posts: 583
  • Post quality +59/-0
Re: I'm going to cry if I don't get some help...
« Reply #1 on: July 27, 2012, 06:51:54 PM »
Just to make sure you are aware, the code checks the button once and then goes into a forever loop locking the output state depending on the button state when the PIC powers-up. So it should not change after initial power up, unless you have the watchdog timer enabled causing the PIC to reset from a timeout.
[Quote from Gamermodz via Viking forums]
Don't be jealous your not half as smart. I hate ****tards like you. An ignorant redneck. Your nothing but a posing ******. Get the **** out of here, really, your claim to fame is an open source rapid fire code? You make me laugh. You think you have control over the modding market?  You couldn't create what I can and do. You are too ignorant with your outrageous assumptions and accusations. [/Quote]

Offline Anonamous

  • The Unknown Identity
  • Granny Spanker
  • *
  • Posts: 472
  • Post quality +14/-1
  • Gender: Male
  • Electrical Engineering Student
Re: I'm going to cry if I don't get some help...
« Reply #2 on: July 27, 2012, 08:05:44 PM »
I'm sorry, but I am not licensed to give you that kind of help :p

Offline frenulem - No.5417

  • Ultimate Badass
  • Blogs & Media Team
  • Acid Modder
  • *
  • Posts: 633
  • Post quality +23/-0
  • Gender: Male
  • Learning Pascal Cuz i'm dumb and 'Ting
Re: I'm going to cry if I don't get some help...
« Reply #3 on: July 29, 2012, 07:03:09 PM »
i may be being stooopid here but if you make it a pull down resistor. Then again i am not a programmer, just a simple fiddler...with electronics that is

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal