mmm, are you saying PWM stops when you jump CCP1 to RB0? what about if you do a simple blink on this RB0 pin... or do a simple IF THEN on RB0
IF PORTB.0 = 1 then DoSomething or Start HPWM
maybe this pin is burn now![]()
mmm, are you saying PWM stops when you jump CCP1 to RB0? what about if you do a simple blink on this RB0 pin... or do a simple IF THEN on RB0
IF PORTB.0 = 1 then DoSomething or Start HPWM
maybe this pin is burn now![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
So you are saying that my code is right and the pin is just acting weird? If it is burned, I have like 8 more PIC chips. I just want to make sure that the problem is fixed before I burn another one. So I will test this PORTB.0 with a simple blink program to see if it responds at all. I'll let you know what happens. Thanks again for your continued input.
Do the RB0 test before using others.
BTW, i'm about setting up a board to do something like this for testing. ì'll post the code here.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
This one use RB0 interrupt handler routine.
Code:' INT0 with PWM ' ============= ' ' File name : INT0_PWM.bas ' Company : Mister E ' Programmer : Steve Monfette ' Date : 02/03/2005 ' Device : PIC18F2320 ' ' ' This program generate 3.6Khz @ 25% duty PWM on CCP1 pin. ' ' CCP1 pin is connected to RB0 pin via 1k resistor. ' ' Program blink a led on PORTB.6 while generating PWM. ' Each rising edge of PWM, PORTB.7 is toggle. This will ' generate 1.8Khz 50% duty on this PORTB.7 pin. ' ' We will use Interrupt on RB0(INT0) pin to detect rising edge ' Hardware Definition ' =================== ' DEFINE LOADER_USED 1 DEFINE OSC 20 TRISB=%00000001 ' PORTB.0 as input TRISC.2=0 ' PORTC as output ADCON1=$0F ' disable A/D converter ' Interrupt definition ' ==================== ' INTCON=%10010000 ' Enable global interrupt ' Enable INT0 interrupt (RB0) INTCON2.6=1 ' Enable INT0 on rising edge ON interrupt goto RB0_interrupt ' Variable definition ' =================== ' Tmr2dutyvar VAR WORD DelayLoop var word ' PWM signal generation ' ===================== ' Tmr2dutyvar=86 ' load duty time duration PR2=$57 ' load frequency period (PWM freq=3.6 KHZ) ' set Duty cycle ' -------------- ' CCP1CON.5=Tmr2dutyvar.1 CCP1CON.4=Tmr2dutyvar.0 CCPR1L =(tmr2dutyvar>>2) T2CON=%00000110 ' start timer 2 ' set prescaler = 16 CCP1CON = %00001100 ' pwm mode for CCP1 ' Main Loop ' ========= ' ' Stupid led blink on PORTB.6... ' Start: toggle PORTB.6 for delayloop = 1 to 50000 pauseus 5 next goto start ' Interrupt routine ' ================= ' ' toggle PORTB.6 each rising edge on it. ' disable RB0_interrupt: toggle PORTB.7 INTCON.1=0 ' reset INT0 interrupt flag resume enable
Last edited by mister_e; - 3rd March 2005 at 04:32.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
By polling INT0 flag bit... no interrupt handler
Code:' INT0 polling with PWM ' ===================== ' ' File name : INT0_poll_PWM.bas ' Company : Mister E ' Programmer : Steve Monfette ' Date : 02/03/2005 ' Device : PIC18F2320 ' ' ' This program generate 3.6Khz @ 25% duty PWM on CCP1 pin. ' ' CCP1 pin is connected to RB0 pin via 1k resistor. ' ' Program blink a led on PORTB.6 while generating PWM. ' Each rising edge of PWM, PORTB.7 is toggle. This will ' generate 1.8Khz 50% duty on this PORTB.7 pin. ' ' We will check INTCON.1 (Interrupt on RB0(INT0) flag bit) pin to ' detect rising edge ' Hardware Definition ' =================== ' DEFINE LOADER_USED 1 DEFINE OSC 20 TRISB=%00000001 ' PORTB.0 as input TRISC.2=0 ' PORTC as output ADCON1=$0F ' disable A/D converter ' Interrupt definition ' ==================== ' INTCON=%00010000 ' Disable global interrupts ' Enable INT0 interrupt (RB0) INTCON2.6=1 ' Enable INT0 on rising edge ' Variable definition ' =================== ' Tmr2dutyvar VAR WORD DelayLoop var word ' PWM signal generation ' ===================== ' Tmr2dutyvar=86 ' load duty time duration PR2=$57 ' load frequency period (PWM freq=3.6 KHZ) ' set Duty cycle ' -------------- ' CCP1CON.5=Tmr2dutyvar.1 CCP1CON.4=Tmr2dutyvar.0 CCPR1L =(tmr2dutyvar>>2) T2CON=%00000110 ' start timer 2 ' set prescaler = 16 CCP1CON = %00001100 ' pwm mode for CCP1 ' Main Loop ' ========= ' ' Stupid led blink on PORTB.6 while testing INT0 flag bit ' Start: toggle PORTB.6 for delayloop = 1 to 50000 pauseus 5 if INTCON.1 then INTCON.1=0 toggle PORTB.7 endif next goto start
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Is there any reason why I can't get the process to start when PORTA.2 goes high?? I haven't rewired the HPWM/RB0 yet, but that should not matter. The PIC should at least shift the vertical clocks before even checking the reset (interrupt flag). Are my registers set correctly for analog input to PORTA.0 and digital input to PORTA.2??
to have analog on PORTA.0
ADCON1=%00001110
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks