Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
The animation demo' in Main is not really the "night rider" effect. This is what it looks like;I like to know is your project LEDs moving like night rider effect?
Yes I do.Do you have an idea how to do a knight rider effect on direct IO port without using charliplexing.
ISR_Enter ;Context save
;interrupt on 256uS
;256X64=16384
;61Hz PWM frequency
bcf INTCON,T0IF ;clear TimerO int flag
Check_Duty ;
movf Duty,W ;
xorwf LED0,W ;Brightness variable
skpnz
bcf Shadow,0
movf Duty,W
xorwf LED1,W ;Brightness variable
skpnz
bcf Shadow,1
movf Duty,W
xorwf LED2,W ;Brightness variable
skpnz
bcf Shadow,2
movf Duty,W
xorwf LED3,W ;Brightness variable
skpnz
bcf Shadow,3
movf Shadow,W ;update PORTB
movwf PORTB
incf Duty,F ;update Duty
btfss Duty,6 ;64 levels??
goto Exit_ISR
clrf Duty
movf S_Shadow,W ;pre load the mask LED's
movwf Shadow_B
Exit_ISR ;restore Context
retfie
Hi Suraj,
It's difficult to help you with your problem without schematic and well commented code.
Mike
;
; 50 usec (100 cycle) interrupts, approx 50% ISR "overhead"
;
; 100 pwm "steps", 200 Hz refresh rate, 5 msec frame rate
;
org 0x0004
radix dec
isr
movwf w_isr ; save W-reg |B?
swapf STATUS,W ; don't change STATUS bits |B?
movwf s_isr ; save STATUS reg |B?
clrf STATUS ; bank 0 |B0
movf PCLATH,W ; get PCLATH |B0
movwf p_isr ; save PCLATH |B0
clrf PCLATH ; page 0 |B0
;
; reload Timer 0 for 50 usec interrupts (8 Mhz, prescaler 1)
; for a 200 Hz refresh rate and a 5 msec frame rate
;
movlw -100+2 ; 100 500-nsec ticks = 50 usecs |B0
addwf TMR0,F ; add to free running TMR0 reg |B0
bcf INTCON,TMR0IF ; clear Timer O interrupt flag |B0
;
; do a 1/100th pwm 'step', 25 cycles (isochronous)
;
movf led+0,W ; led0 pwm value, 0..99 |B0
subwf dcy,W ; C = led0 => dcy |B0
rrf shadow,F ; |B0
movf led+1,W ; led1 pwm value, 0..99 |B0
subwf dcy,W ; C = led1 => dcy |B0
rrf shadow,F ; |B0
movf led+2,W ; led2 pwm value, 0..99 |B0
subwf dcy,W ; C = led2 => dcy |B0
rrf shadow,F ; |B0
movf led+3,W ; led3 pwm value, 0..99 |B0
subwf dcy,W ; C = led3 => dcy |B0
rrf shadow,F ; |B0
movf led+4,W ; led4 pwm value, 0..99 |B0
subwf dcy,W ; C = led4 => dcy |B0
rrf shadow,F ; |B0
movf led+5,W ; led5 pwm value, 0..99 |B0
subwf dcy,W ; C = led5 => dcy |B0
rrf shadow,F ; |B0
movf led+6,W ; led6 pwm value, 0..99 |B0
subwf dcy,W ; C = led6 => dcy |B0
rrf shadow,F ; |B0
movf led+7,W ; led7 pwm value, 0..99 |B0
subwf dcy,W ; C = led7 => dcy |B0
rrf shadow,W ; W = led 'step' output |B0
; xorlw 0xFF ; for active hi outputs |B0
movwf PORTB ; update LEDs |B0
;
; bump duty cycle, 5 cycles (isochronous)
;
incf dcy,F ; dcy++, 0..99 inclusive |B0
movf dcy,W ; |B0
xorlw 100 ; end of 5 msec frame? |B0
skpnz ; no, skip, else |B0
clrf dcy ; reset duty cycle counter |B0
;
; restore context, 8 cycles (isochronous)
;
isr_xit
movf p_isr,W ; |B0
movwf PCLATH ; restore PCLATH |B0
swapf s_isr,W ; |B0
movwf STATUS ; restore STATUS |B0
swapf w_isr,f ; don't screw up STATUS |B0
swapf w_isr,W ; restore WREG |B0
retfie ; return from interrupt |B0
;
pos_01 setled 00,00,00,00,99,70,40,20
movlw 60/5 ;
call delay5 ; wait 60 msecs
setled 00,00,00,99,70,40,20,05
movlw 60/5 ;
call delay5 ; wait 60 msecs
setled 00,00,99,70,40,20,05,00
movlw 60/5 ;
call delay5 ; wait 60 msecs
......
;
; delay WREG * 5 msec "frames", returns during step 0
;
delay5
movwf x5msec ; save x5 msec delay value |B0
wait0 movf dcy,W ; end-of-frame, dcy == 0? |B0
bnz wait0 ; no, branch (wait), else |B0
decf x5msec,F ; x5 msec timer timed out? |B0
skpnz ; no, skip, else |B0
return ; timed out so return |B0
waitx movf dcy,W ; wait for non-zero dcy value |B0
bnz wait0 ; branch, wait for next frame |B0
goto waitx ; else, wait for non-zero dcy |B0
;
Hi Mike, K8LH what a code thats a nice method I'll use your method.
Thanks for the big support![]()