View previous topic :: View next topic |
Author |
Message |
Ami
Joined: 02 Sep 2007 Posts: 5 Location: Venezuela
|
shutdown of a CCP mode |
Posted: Sat Sep 15, 2007 6:57 pm |
|
|
Hi, thanks PCM programmer for the help,the eeprom worked realy good. In this time I need help with the shutdown modes, I understand that there is 14 ways to shutdown the PWM of 18F4550. I need one that turn on the ccp and stop with a single dip-switch.
This is one of the ways, but I don't know if it works:
"VIL" on INT pin for CCP_SHUTDOWN_ON_INT0, what does it mean VIL
there is other mode that works with a dip-switch?... thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 15, 2007 7:11 pm |
|
|
Please don't direct the question just to me. Give everyone a chance to answer. |
|
|
Guest
|
Re: shutdown of a CCP mode |
Posted: Sat Sep 15, 2007 8:26 pm |
|
|
Ami wrote: | Hi, thanks PCM programmer for the help,the eeprom worked realy good.
ESTO ES PARA QUIEN PUEDA RESPONDER! no solo para PCM programmer.
sorry PCM programmer, I didn't ask only to you.
In this time I need help with the shutdown modes, I understand that there is 14 ways to shutdown the PWM of 18F4550. I need one that turn on the ccp and stop with a single dip-switch.
This is one of the ways, but I don't know if it works:
"VIL" on INT pin for CCP_SHUTDOWN_ON_INT0, what does it mean VIL
there is other mode that works with a dip-switch?... thanks |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 16, 2007 2:09 pm |
|
|
Post your compiler version.
I was trying to create a demo program for you. But I looked at the .LST
file and I think there's a problem with the Shutdown mode code in
the CCS setup_ccp1() function. I think it will require some work-around
code. Post your compiler version so I can test it with your version. |
|
|
Ami
Joined: 02 Sep 2007 Posts: 5 Location: Venezuela
|
RE: |
Posted: Sun Sep 16, 2007 2:23 pm |
|
|
The version is 4.013 PCWH Compiler |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 16, 2007 3:56 pm |
|
|
Here's some sample code to test the PWM shutdown mode. You need to
put a pull-up resistor on the "RB0/AN12/INT0/FLT0/SDI/SDA" pin of the
PIC. You can use 4.7K or 10K ohms. Then connect a push-button
switch to that pin (and to the pullup). Connect the other side of the
switch to ground. So normally the FLT0 pin will be at +5v, but when
you press the switch it will go to 0 volts.
This program runs in "Full Bridge" mode. When it's in "forward" mode,
you should see a PWM signal on the P1D pin. When it's in "reverse", you
should see a PWM signal on the P1B pin. It will switch between forward
and reverse every 5 seconds.
When you press the Shutdown switch, it should set all PWM pins, P1A,
P1B, P1C, and P1D to 0 volts. When you release the switch, it should
start putting out PWM signals again.
I don't have my 18F4550 board available this afternoon, so I can't test
this program in hardware. But I've looked at the .LST file and I think
it will work. I checked the .LST file for versions 4.013 and 4.056.
Code: |
#include <18F4550.h>
#fuses XT,NOWDT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
//-----------------------------------------
// Setup the PWM shutdown mode so it sets the PWM outputs
// low, if the FLT0 pin is held at a low level. Set it to
// turn the PWM back on again if the FLTO pin is set high.
#define CCP_SHUTDOWN_MODE (CCP_SHUTDOWN_ON_INT0 | \
CCP_SHUTDOWN_AC_L | \
CCP_SHUTDOWN_BD_L | \
CCP_SHUTDOWN_RESTART)
void setup_enhanced_pwm(int8 pwm_mode, int32 eccp_mode)
{
#byte ECCP1AS = 0xFB6
#byte ECCP1DEL = 0xFB7
setup_ccp1(pwm_mode);
ECCP1AS = eccp_mode >> 16;
ECCP1DEL = eccp_mode >> 24;
}
//=================================
void main()
{
// Setup the ECCP for PWM in full bridge mode. Also
// enable the shutdown mode so it's controlled by the
// logic level on the FLT0 pin. (0 = PWM off, 1 = on).
setup_enhanced_pwm(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H, CCP_SHUTDOWN_MODE);
setup_timer_2(T2_DIV_BY_1, 255, 1);
set_pwm1_duty(100);
// Switch the H-Bridge outputs between forward
// and reverse every 5 seconds.
while(1)
{
// Run forward for 5 seconds.
setup_enhanced_pwm(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H, CCP_SHUTDOWN_MODE);
delay_ms(5000);
// Run in reverse for 5 seconds.
setup_enhanced_pwm(CCP_PWM_FULL_BRIDGE_REV | CCP_PWM_H_H, CCP_SHUTDOWN_MODE);
delay_ms(5000);
}
} |
|
|
|
Ami
Joined: 02 Sep 2007 Posts: 5 Location: Venezuela
|
|
Posted: Sun Sep 16, 2007 4:51 pm |
|
|
Thanks, it works!!!! |
|
|
eiby
Joined: 07 Oct 2008 Posts: 3
|
|
Posted: Tue Oct 21, 2008 7:58 pm |
|
|
Hello, I've been working with eccp. I found this code and I tried to use it with the pic 18F458. Does it work ? Because I can't make it work as it is.
I have 4.065 pcwh. _________________ Best regards,,
Abraham Guerrero |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|