|
|
View previous topic :: View next topic |
Author |
Message |
sandropiovesana
Joined: 06 May 2008 Posts: 9
|
Problem with shutdown on PIC16f684 |
Posted: Wed Jun 04, 2008 8:42 am |
|
|
Hi All,
I have a problem when i shutdown (in firmware) the bridge because i don't have the shutdown condition indicated in my software but i have all low level on P1A,P1B,P1C,P1D. (i want high level).
I use CCS 4.073, MPLAB 8.10 and ICD2 (only for programming).
How can i have high level on P1A,P1B,P1C,P1D (using ECCP)?
How can i have high level on P1A,P1B,P1C,P1D (using another idea)?
This is my code:
Code: |
#include <16F684.h>
#DEVICE ADC=10
#BIT ECCPASE = 0x17.7
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWDT //No Watch Dog Timer
#FUSES PUT //Power Up Timer
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //NO Fail-safe clock monitor enabled
#USE delay(clock=8000000)
#USE FAST_IO(A)
#USE FAST_IO(C)
#define CCP1_LOW_SPD 70 // 70% Duty-Cycle
#define CCP1_HIGH_SPD 100 // 100% Duty-Cycle
// PORT CONTROL
#define TRISA_SETUP 0b11111110
#define TRISC_SETUP 0b11000011 // Prima con RS232 era 0b11011100
#define BJT 40 // PIN_RA0
#define VREF 41 // PIN_RA1
#define VAMP 42 // PIN_RA2
#define VPP 43 // PIN_RA3
#define JMP2 44 // PIN_RA4
#define JMP1 45 // PIN_RA5
#define VCC_2 56 // PIN_RC0
#define POL 57 // PIN_RC1
#define P1D 58 // PIN_RC2
#define P1C 59 // PIN_RC3
#define P1B 60 // PIN_RC4
#define P1A 61 // PIN_RC5
/* Global definitions used to indicate the state of a pin */
#define LOW 0
#define HIGH 1
//----------------------------------------------------------------------------
//- - MAIN - -
//----------------------------------------------------------------------------
void main(void)
{
setup_oscillator(OSC_8MHZ);
Set_Tris_A(TRISA_SETUP);
Set_Tris_C(TRISC_SETUP);
setup_adc_ports(sAN2|sAN4|VSS_VREF);
setup_adc(ADC_CLOCK_INTERNAL);
SETUP_TIMER_2 (T2_DIV_BY_4, 100, 1);
set_pwm1_duty (CCP1_LOW_SPD);
ENABLE_INTERRUPTS(GLOBAL);
while (TRUE)
{
SETUP_CCP1 (CCP_PWM_L_H | CCP_PWM_FULL_BRIDGE | CCP_SHUTDOWN_AC_H | CCP_SHUTDOWN_BD_H);
delay_ms(1000);
ECCPASE = 1;
delay_ms(1000);
ECCPASE = 0;
}
} |
Datasheet:
11.4.4 ENHANCED PWM
AUTO-SHUTDOWN MODE
The PWM mode supports an Auto-Shutdown mode that
will disable the PWM outputs when an external
shutdown event occurs. Auto-Shutdown mode places
the PWM output pins into a predetermined state. This
mode is used to help prevent the PWM from damaging
the application.
The auto-shutdown sources are selected using the
ECCPASx bits of the ECCPAS register. A shutdown
event may be generated by:
• A logic ‘0’ on the INT pin
• Comparator 1
• Comparator 2
• Setting the ECCPASE bit in firmware |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 05, 2008 12:15 pm |
|
|
The setup_ccp1() function is not writing to the ECCPAS register.
That's a bug. To fix it, add this line above main():
Code: | #byte ECCPAS = 0x017 |
Then add this line just after the setup_ccp1() line in your program.
This will manually setup the ECCPAS register.
Code: |
ECCPAS = make8(CCP_SHUTDOWN_BD_H | CCP_SHUTDOWN_AC_H, 2); |
I have reported this to CCS. |
|
|
sandropiovesana
Joined: 06 May 2008 Posts: 9
|
|
Posted: Fri Jun 06, 2008 12:57 am |
|
|
Thank You very much!!!
Sandro |
|
|
|
|
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
|