-1

datasheet for PIC18Fxx2

datasheet related to the 7segs that I am using can be obtained right here

edit(15/4/2013): code below is the instruction word for PORTD

ldig    SET b'00001000' ;for rght digit
rdig    SET b'00000100' ;for left digit

instruction words for TRISB, TRISD, PORTB and PORTD when the code is first executed

CLRF    TRISB   ;port B as output
CLRF    TRISD   ;port D as output
CLRF    PORTD   ;clear port D not to select any digit
SETF    PORTB   ;set port B to off all segments

I want to make two different digits displayed on 2 seven-segment LED displays using assembly. I was trying with the code listed below and it does not work. notes: rdig = right panel, ldig = left panel, disp1 represent 1, and so on.

loop    MOVFF   disp1, PORTB
        MOVLW   rdig    ;select only the left display
        MOVWF   PORTD   ;unit to be on

        MOVFF   disp8, PORTB
        MOVLW   ldig    ;select only the left display
        MOVWF   PORTD   ;unit to be on

        bra     loop

the output is supposed to be 81 (on the seven-segment display) none of the number appears. only some kind of dim light shows up on each panel. the code, however works if i'm trying to display only one number on either side of the seven-segment display.

loop        MOVFF   disp8, PORTB
            MOVLW   ldig    ;select only the left display
            MOVWF   PORTD   ;unit to be on

            bra     loop

edit: I tried to add a small delay (2 microsec) using TMR0N (b'00000000' instruction word, tmrL = FF, tmrH = FB) to each number display request as below, and only number 1 appears on the right panel.

loop    MOVFF   disp1, PORTB
    MOVLW   rdig    ;select only the left display
    MOVWF   PORTD   ;unit to be on
    call    delay

    MOVFF   disp8, PORTB
    MOVLW   ldig    ;select only the left display
    MOVWF   PORTD   ;unit to be on
    call    delay

    bra     loop

instruction settings for TMR0N

initwrd SET 0x00
tmrH    SET 0xFF
tmrL    SET 0xFB
Arif Samin
  • 257
  • 1
  • 9
  • You are supposed to invent solutions, build them from small building blocks. You are not supposed to find ready-made, complete solutions online. It's not the Internet that's lacking. It's ... – Alexey Frunze Apr 13 '13 at 11:05
  • @AlexeyFrunze I am not expecting to have someone to show me how to do it from scratch. I am doing well so far with what I have learned for 18F452 coding. However I've stuck with this part for the whole week and need some solutions. – Arif Samin Apr 13 '13 at 11:20
  • How about identifying the specific problem(s) first? Being stuck, the whole week, school, etc is all irrelevant. Show us specifically what you're having difficulties with and what you've already tried, namely your ideas that failed and your code that failed. As stated your question/problem is pretty vague and can't be addressed. Improve it. – Alexey Frunze Apr 13 '13 at 11:25
  • @AlexeyFrunze okay then. thanks for your insight. – Arif Samin Apr 13 '13 at 11:37
  • I believe you need to include the schematics for your device and the datasheet for the 7-seg LEDs. Also you do not define things like `disp1`, `PORTB`, `rdig`. How is one supposed to help you without all this information? – Alexey Frunze Apr 13 '13 at 14:37
  • @AlexeyFrunze hmm, i thought that things like PORTB and extra stuffs like disp1 and rdig can be figured out thru common sense. Guess I need much more guidance before posting a question. – Arif Samin Apr 13 '13 at 14:58
  • The thing is, when you omit details, nobody knows precisely what and where you may be doing wrong or what's supposed to be right. – Alexey Frunze Apr 13 '13 at 15:16

1 Answers1

0

Assuming that PORTD has the enables per each digit set correctly and same for hardware connections, then your code is correct. The only mistake you have is the amount of delay. Start with 1 ms and increase until you get a display of the two digits with no visible flickering. This amount of delay depends on the number of 7-seg displays you are using (again to avoid flickering). 2 usec is simply not enough. I have been working with PICs for ages, this should work.

The Byzantine
  • 619
  • 1
  • 6
  • 21
  • I've changed the delay to 1ms as u suggest but the 7seg displays still can only produce 1 on the right panel. If you're firm with your answer maybe the schematic/datasheet for my 7segs is a little bit different or something else. I'll try to get the schematic from my lecturer first. Its weekend so I cant reach him for now. – Arif Samin Apr 14 '13 at 08:46
  • Instead of using HW timer for delay, just write a SW Delay subroutine to give 1ms .. a simple loop to run for that time would be sufficient. Try that, if not. I see nothing wrong with your code. – The Byzantine Apr 16 '13 at 17:17