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

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 182 times
User avatar
chloe4479
 
Posts: 19
Joined: Fri Jan 06, 2017 4:19 pm
Has thanked: 10 times
Have thanks: 5 times

Advertisement

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 187 times
If your hardware is not working as expected, try looking here first:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936

If you find any posts that are useful, please click on the 'thumbs up' icon next to Quote button on that post.

For this message the author medelec35 has received thanks:
Benj(Thu Jan 12, 2017 11:34 am)
Rating:5.88%
 
User avatar
medelec35
Valued Contributor
Valued Contributor
 
Posts: 6863
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2352 times
Have thanks: 3021 times

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

For this message the author chloe4479 has received thanks:
Benj(Thu Feb 09, 2017 1:23 pm)
Rating:5.88%
 
User avatar
chloe4479
 
Posts: 19
Joined: Fri Jan 06, 2017 4:19 pm
Has thanked: 10 times
Have thanks: 5 times


Return to C and ASM Programming

Who is online

Users browsing this forum: No registered users and 2 guests