PIC16F877A Delay Using Assembly Language

Discussion in 'Embedded Systems and Microcontrollers' started by yuchan, Oct 22, 2015.

  1. yuchan

    Thread Starter New Member

    Oct 22, 2015
    2
    1
    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.
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    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.
     
  3. yuchan

    Thread Starter New Member

    Oct 22, 2015
    2
    1
    Thanks a lot. IT WORKS:)
     
    JohnInTX likes this.
  4. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    I promise to use this power only for good.
     
Loading...