View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
setup_ccp1(CCP_OFF); CCS 4129 -> 4131 |
Posted: Thu Mar 29, 2012 4:59 am |
|
|
Hi
New compiler new behavior?
I wonder if the 4131 do CCP_OFF correct. In 4129 it make CCP1 pin high-Z or input, and Clear CCP1CON, but 4131 only clear the 4 LSB of CCP1CON. In the data sheet Microchip recommend to make "CLRF CCP1CON" to avoid int triggering.
Is 4129 or 4131 correct?
PIC18F25K22
Code: | //4129
.................... setup_ccp1(CCP_OFF);
3BC8: BSF TRISC.TRISC2
3BCA: CLRF CCP1CON
3BCC: CLRF PWM1CON
3BCE: CLRF ECCP1AS
3BD0: MOVLW 01
3BD2: MOVWF PSTR1CON
3BD4: MOVLW FC
3BD6: MOVLB F
3BD8: ANDWF x49,F
3BDA: MOVLW 00
3BDC: IORWF x49,F
//4131
.................... setup_ccp1(CCP_OFF);
3B8E: MOVLW F0
3B90: ANDWF CCP1CON,F
//4129 & 4131 Same code!
.................... setup_ccp1(CCP_PWM);
3B3E: BCF TRISC.TRISC2
3B40: BCF LATC.LATC2
3B42: MOVLW 0C
3B44: MOVWF CCP1CON
3B46: CLRF PWM1CON
3B48: CLRF ECCP1AS
3B4A: MOVLW 01
3B4C: MOVWF PSTR1CON
3B4E: MOVLW FC
3B50: MOVLB F
3B52: ANDWF x49,F
3B54: MOVLW 00
3B56: IORWF x49,F |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2012 3:32 pm |
|
|
Quote: | In the data sheet Microchip recommend to make "CLRF CCP1CON" to avoid int triggering. |
I assume you mean this section below:
Quote: |
14.1 Capture Mode
14.1.4 CCP PRESCALER
Switching from one capture prescaler to another does
not clear the prescaler and may generate a false
interrupt. To avoid this unexpected operation, turn the
module off by clearing the CCPxCON register before
changing the prescaler.
|
According to the data sheet, if you clear the bottom 4 bits of CCP1CON,
you will reset the CCP module. I think that's good enough.
Quote: |
REGISTER 14-1: CCPxCON: STANDARD CCPx CONTROL REGISTER
bit 3-0 CCPxM<3:0>: ECCPx Mode Select bits
0000 = Capture/Compare/PWM off (resets the module) |
|
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Fri Mar 30, 2012 9:45 am |
|
|
Hi
Hmmm after some real test in hardware I not agree, 4131 is doing it right.
After a setup_ccp1(CCP_OFF); CCP1 pin is "L =0V". I expect it to "float".
In 4129 it is floating. And after a PIC reset CCP1 is floating.
Some feedback please? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Fri Mar 30, 2012 10:51 am |
|
|
I think 4.131, _is_ doing it right. Turning off the CCP should mean just that. Turn off the CCP, but leave the pin driving. Otherwise you may well risk cataclysmic failure. If you want the pin to float, then you have the option to simply turn off the CCP, and then use an 'output_float' instruction. Floating 'automatically', would be the same as if when you turned off the UART the pin floated. You really want the pin to stay in the 'idle' state, until _you_ say otherwise. I think CCS have actually switched to the safer, and more logical setting. They have probably had a complaint from somebody driving a power PWM setup, who wants the pin to remain driving.
Best Wishes |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Fri Mar 30, 2012 11:01 am |
|
|
Thanks for giving it some time both of you. I understand the explanation, and if I think a little more about it, it make sense. |
|
|
|