PIC18F4520 Counter 9999 Assembly issue.

Discussion in 'Embedded Systems and Microcontrollers' started by LordMohd, May 28, 2011.

  1. LordMohd

    Thread Starter New Member

    May 28, 2011
    Hello everyone.
    I'm in a bit of a problem here, with my experiment which is supposedly a counter from 0000 to 9999.
    I've wrote the assembly program to do the counting, which works...almost well.

    The problem is, I'm limited to use Port-D as OUTPUT for ALL the 4 Seven-Segment display LED's , while using 4 bits of Port-C to toggle the LED's on and off contentiously.

    The first digit starts to count from 1 to 9, then it goes off, the second digit displays 1, then it goes off, then the first digit starts counting again.
    Same happens when the first and second reach 99, they both turn off and the third digit displays 1, ETC...
    I need ALL the LED's to be on while the counting process is happening.

    I'd appreciate any help ASAP on creating an interrupt that will cause Port-C to light all the LED's at the same time while NOT displaying the same number on all of them and mixing up the counting.

    Also, there might be a slight problem with the counting in the assembly program which I can't figure out, if someone could point it out I'd be thankful to them.

    -Microcontroller : PIC18F4520
    -Programmer : PICKit3
    -Software : MPLAB IDE v8.63
    -Language : Assembly language (NOT C-Language)

    -Hardware : Port-D Bits 0-6 connected to a DM74LS244 TristateBuffer IC then 330Ω R for each line which are connected to four common cathode LED 7-Seg. Display through out A=Port-D.Bit0 ,B=Port-D.Bit1 ,C=Port-D.Bit2 ,D=Port-D.Bit3 ,E=Port-D.Bit4 ,F=Port-D.Bit5 ,G=Port-D.Bit6.
    Port-C Bits 0-3 connected to the common cathode of each LED as in order First=Port-C.Bit0, Second=Port-C.Bit1, Third=Port-C.Bit2, Fourth=Port-C.Bit3.

    -Using 4MHz Crystal and the reset hardware is configured with 470Ω R , Pushbutton switch, 0.1μF C , 10kΩ R.

    Here's the project folder attached in the topic.

    Thank you!

  2. beenthere

    Retired Moderator

    Apr 20, 2004