Richard, it worked, Thanks, although it raises as many questions as it answers.
This works
This works, on PortB, why? This should work on PortA. PortB, I tought, would be 8-15.Code:for Avar= 0 to 7 cycle=4 ;cycle is number of cycles of pulse for Duty=0 to 220 step 1 pwm Avar,Duty,cycle next Duty cycle=2 ;cycle is number of cycles of pulse for Duty=220 to 0 step -2 pwm Avar,Duty,cycle next Duty low Avar next Avar
Yes I had used ‘Symbol Port_Pin=PortB’ which would set PortB to 0-7 but now I’m not using Port_Pin in the routine. I remember there is a file somewhere that sets the port numbers but I can ‘t remember what or where it is. I may have changed the default numbering over the years. Oh well, it works and now and I’m happy. I’m surprised I had not seen an example for PWM that used this method to cycle through LEDs. Too easy! thank you both for your input!
Code:; 16F886 @ DEVICE INTRC_OSC,MCLR_ON,BOD_OFF,WDT_OFF,LVP_OFF define osc 8 ;------[ Set Hardware ]------------------------------------------------------ OSCCON=$70 '$70=8MHz, $60=4MHz ANSEL=$00 ANSELH=$0 ADCON0=$00 CM1CON0=0 CM2CON0=0 OPTION_REG=0 ; INTOC RB0 set to interrupt on falling edge PORTA=%00000000 PORTB=%00000000 PORTC=%00000000 ' RAC6&7 set with Hserout command TRISA=%00000011 ' PORTA RA0 & RA1 input all other output TRISB=%00000000 ' PORTB all set to Onput TRISC=%00000000 ' PortC RC7&RC6 for hserout ;--[ VARIBLES, CONSTATNS ]------------------------------------------------- ; Symbol Port_Pin=PortB ; To define PortB port numbers start at RB.0 Avar var byte Duty var byte Cycle var byte ;--[ Main Program ]------------------------------------------------------------- Start: gosub FadeTest ;--[ Routine for fade on and fade off LEDs]------------------------------------ FadeTest: for avar = 0 to 7 cycle=4 ;cycle is number of cycles of pulse for Duty= 0 to 220 step 1 pwm Avar,Duty,cycle next Duty cycle=2 ;cycle is number of cycles of pulse for Duty= 220 to 0 step -2 pwm Avar,Duty,cycle next Duty low Avar next Avar Return end




Bookmarks