PIC16F877A Delay Using Assembly Language

Thread Starter

yuchan

Joined Oct 22, 2015
2
I wrote a program to display few texts on 6X5 led display using MPASM(Proteus). The PIC has a 4MHz clock frequency. I was using the same DELAY 1 second instruction that I used on 4X4 led display(working well). But when it comes to my 6X5 led display, the DELAY caused the program to freeze. It wont execute the next instructions. I uploaded the code just in case.
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
I ran up your code and it looped around OK without hanging up on the timer.
Your config makes it an XT oscillator instead of the LP in the comments. I added a proper _CONFIG
Rather than try to catch the timer being =39, I changed the code to load TMR0 with 271 and have it count up and roll over, setting T0IF in INTCON. Your /256 prescaler makes it unlikely but constructs like that can be problematic.
I added some more acceptable constructs for RAM declarations (cblock) and bank switching using banksel - preferred methods.
Finally, I added "INCLUDE P16F877A.inc" to include all of the correct names and addresses of the PIC's registers. Don't use your own.
Other than the oscillator, I didn't see anything that would stop it from at least running around.

Good luck.
 

Attachments

Thread Starter

yuchan

Joined Oct 22, 2015
2
I ran up your code and it looped around OK without hanging up on the timer.
Your config makes it an XT oscillator instead of the LP in the comments. I added a proper _CONFIG
Rather than try to catch the timer being =39, I changed the code to load TMR0 with 271 and have it count up and roll over, setting T0IF in INTCON. Your /256 prescaler makes it unlikely but constructs like that can be problematic.
I added some more acceptable constructs for RAM declarations (cblock) and bank switching using banksel - preferred methods.
Finally, I added "INCLUDE P16F877A.inc" to include all of the correct names and addresses of the PIC's registers. Don't use your own.
Other than the oscillator, I didn't see anything that would stop it from at least running around.

Good luck.
Thanks a lot. IT WORKS:)
 
Top