ahhhh, there's the kick i needed.
I also am working on a 3digit 7seg led display, using modified code
(read: massively mangled stolen code :P)
and was doing the same thing..
(pausing, and calling/gosubing the bin2seg lookup)
so some ideas i was wrestling with just got answered?..Code:MOVF _led1data,W call bin2seg MOVWF PORTD bsf _led1digit call dly7seg bcf _led1digit movf _led2data,W call bin2seg movwf PORTD bsf _led2digit call dly7seg bcf _led2digit movf _led3data,W call bin2seg movwf PORTD bsf _led3digit call dly7seg bcf _led3digit
1)thinking should look digits up in the main loop? and use the already "lookedup" variables in the interupt routine.
2)now the one digit per interrupt, I had thought about, but couldn't figure out how to do. (put on back burner, until I saw this)
little trickier.. without a gosub?
would something like this work? (seems long way no?)
on the right track?Code:if digitloop=3 then digitloop=0 'only three digits digitloop=digitloop+1 'next digit if digitloop=1 goto digit1 'which digit we displaying? endif if digitloop=2 goto digit2 endif digit3: 'wasn't 1 or 2 so must be 3! PORTC = SEGDEF3 'output "prelookedup" data PORTE = 3 'turn digit on goto dispdone 'goto finish digit2: 'doing digit 2 PORTC = SEGDEF2 'output "prelookedup" data PORTE = 5 'turn digit on goto dispdone 'goto finish digit1: 'doing digit1 PORTC = SEGDEF1 'output "prelookedup" data PORTE = 6 'turn digit on goto dispdone 'goto finish DISPDONE: 'reload timer T1CON.0 = 0 ; stop timer TMR1H = %11111100 TMR1L = %00011111 T1CON.0 = 1 ; restart timer @ INT_RETURN 'exit int routine
should the timer be stopped at the beginning of the routine?
now in the main, will we need 3 lookup tables? can lookup into an array? or how about...
(I was attempting mine in assembly, but so as not to hijack the thread, did this way)Code:n=1 'to be replaced with digit1 variable (N=N1) gosub bin2seg segdef1=segdef n=2 'digit2 gosub bin2seg segdef2=segdef n=3 'digit3 gosub bin2seg segdef3=segdef BIN2SEG: LookUp n,[132,175,193,137,170,152,144,143,128,136,210,251],SEGDEF return




Bookmarks