PIC16F1937 PORTA ISSUE I THINK help

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

User avatar
chloe4479
Posts: 19
Joined: Fri Jan 06, 2017 4:19 pm
Has thanked: 10 times
Been thanked: 5 times
Contact:

PIC16F1937 PORTA ISSUE I THINK help

Postby chloe4479 » Wed Jan 11, 2017 11:19 pm

I am trying g to run this programe which works if I don't use the port a switch, but as soon as I include the switch noting happens.

Basically as soon as porta,0 switch is pressed the count on port b led begins.
However noting happens

What have I done wrong
Asm file uploaded

Chloe
Attachments
TUT8NEW.ASM
(2.26 KiB) Downloaded 239 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 7049
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 1890 times
Been thanked: 2714 times
Contact:

Re: PIC16F1937 PORTA ISSUE I THINK help

Postby medelec35 » Wed Jan 11, 2017 11:52 pm

Hi Chloe,
Attached is a modified ASM file.

The reason why your ASM is not working is because by default with 16F1937 all analogue pins are enabled i.e. port A0 being one of them.
If an analogue pin is enabled then it will not work as a digital input,
So I added BANK3 since to disable an analogue pin you need to clear the corresponding bit of ANSELA (ANalogue SELect port A) Register at location H'18C' (BANK3)
I have also added a delay or LEDs will count far too rapidly.

Martin

Edit: Moved Topic to a more appropriate section.
Attachments
TUT8NEW.ASM
(2.48 KiB) Downloaded 242 times
These users thanked the author medelec35 for the post:
Benj (Thu Jan 12, 2017 11:34 am)
Rating: 5.88%
 
If your hardware is not working as expected, try looking here first:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936

User avatar
chloe4479
Posts: 19
Joined: Fri Jan 06, 2017 4:19 pm
Has thanked: 10 times
Been thanked: 5 times
Contact:

Re: PIC16F1937 PORTA ISSUE I THINK help

Postby chloe4479 » Tue Feb 07, 2017 12:00 am

Thanks Martin

You have a been a great help as always

Chloe
These users thanked the author chloe4479 for the post:
Benj (Thu Feb 09, 2017 1:23 pm)
Rating: 5.88%