CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

shutdown of a CCP mode

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ami



Joined: 02 Sep 2007
Posts: 5
Location: Venezuela

View user's profile Send private message MSN Messenger

shutdown of a CCP mode
PostPosted: Sat Sep 15, 2007 6:57 pm     Reply with quote

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 Sad
there is other mode that works with a dip-switch?... thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 15, 2007 7:11 pm     Reply with quote

Please don't direct the question just to me. Give everyone a chance to answer.
Guest








Re: shutdown of a CCP mode
PostPosted: Sat Sep 15, 2007 8:26 pm     Reply with quote

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 Sad
there is other mode that works with a dip-switch?... thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 2:09 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

RE:
PostPosted: Sun Sep 16, 2007 2:23 pm     Reply with quote

The version is 4.013 PCWH Compiler
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 3:56 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

PostPosted: Sun Sep 16, 2007 4:51 pm     Reply with quote

Thanks, it works!!!! Very Happy
eiby



Joined: 07 Oct 2008
Posts: 3

View user's profile Send private message

PostPosted: Tue Oct 21, 2008 7:58 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 21, 2008 9:18 pm     Reply with quote

This topic is about using the ECCP for the 18F4550. You have a 18F458.
You should search for:
Quote:
18F458 ECCP

Set it to "Search for all terms". You will find topics like this:
http://www.ccsinfo.com/forum/viewtopic.php?t=35134
http://www.ccsinfo.com/forum/viewtopic.php?t=30409
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group