Greatings! I have stated a new project working with PWM and fading LEDs. All is going well until I tried to combine two simple test routines. The first two routines work fine. When I tried to use port indexing with PWM it failed. Can anyone point out my error or does the PWM command have limitations on pin discriptions? Manual says it can be a variable or pin discription, e.g. PortB.0 Is there another way to do this?
PIC16f886, PBP 2.6, using LAB X2 board.
;Cycle through PortB to fade ON then fade OFF eight LEDs in sequence.
Comments please, Thanks.Code:Symbol Port_Pin=PortB Avar var byte Duty var byte Cycle var byte ;more stuff in here ;--[ LED fade ON and fade OFF ]--------- works fine! FadeTest: cycle=4 ;cycle is number of cycles of pulse for Duty=0 to 100 step 1 pwm led1,Duty,cycle next Duty cycle=1 ;cycle is number of cycles of pulse for Duty=100 to 0 step -2 pwm led1,Duty,cycle next Duty low led1 ;end of routine pause 1000 goto FadeTest ;--[ PortB indexing LEDs ]-------------- works fine! IndexTest: for Avar=0 to 7 Port_Pin.0[Avar]=1 pause 250 Port_Pin.0[Avar]=0 pause 250 next goto IndexTest ;--[ FireFlies routine ]------------------- FAILED FireFlies: for Avar=0 to 7 cycle=4 for Duty=0 to 220 step 1 pwm Port_Pin.0[Avar],Duty,cycle next Duty cycle=1 for Duty=220 to 0 step -2 pwm Port_Pin.0[Avar],Duty,cycle next Duty low Port_Pin.0[Avar] ;end of routine Next Avar goto FireFlies
Wayne




Bookmarks