|
|
View previous topic :: View next topic |
Author |
Message |
norman_tan
Joined: 30 Jan 2008 Posts: 27
|
How to set ECCP(full-bridge) in 18f65j10? |
Posted: Fri Mar 21, 2008 8:08 pm |
|
|
Dear all,
I am using the chip 18f65j10 and going to use ECCP(Full-bridge) for Inverter. so I copied codes below from forum. only changed
#include <18F65j10.h>
#fuses HS,NOWDT
#use delay (clock=20000000)
and ECCP1DEL = 0xF79(for 18f65j10 it is so).
I measured with oscilloscope. but there are no any signal on P1A, P1B, P1C, P1D. there are all 0 level forever.
Does Any one meet this problem?
Would you please give me some advice for it?
thanks!
codes:
#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);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Mar 22, 2008 1:20 am |
|
|
That code is from this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=32085
It's intended to test Shutdown mode. It requires a pull-up resistor
to be connected to the FLT0 pin, or won't run.
Also, that program has work-around code in it, because the person it
was written for was using a very early version, vs. 4.013, which didn't
work correctly in ECCP PWM mode. |
|
|
|
|
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
|