I have a problem with my .c when I use a pwm macro. Please, look what I get:
Code: Select all
//PWM0: //ImplΓ©mentations Macro
void FCD_PWM0_Enable(char nIdx)
{
//error checking
#ifndef MX_PWM
#warning "This chip does not have PWM capability"
#else
#ifndef MX_PWM_CNT
#pragma error FCD file error (no MX_PWM_CNT)
#endif
#if (MX_PWM_CNT < 1)
#pragma error FCD file error (MX_PWM_CNT < 1)
#endif
#if (MX_PWM_CNT > 2)
#pragma error FCD file error (MX_PWM_CNT > 2)
#endif
#ifndef MX_PWM_TRIS1
#pragma error FCD file error (no MX_PWM_TRIS1)
#endif
#ifndef MX_PWM_1
#pragma error FCD file error (no MX_PWM_1)
#endif
#if (MX_PWM_CNT == 2)
#ifndef MX_PWM_TRIS2
#pragma error FCD file error (no MX_PWM_TRIS2)
#endif
#ifndef MX_PWM_2
#pragma error FCD file error (no MX_PWM_2)
#endif
#endif
#if (0 == 1)
#ifndef MX_PWM_TRIS1a
#pragma error PWM component error (using alternative, but no MX_PWM_TRIS1a)
#define MX_PWM_ALT_ERROR
#endif
#ifndef MX_PWM_1a
#pragma error PWM component error (using alternative, but no MX_PWM_1a)
#define MX_PWM_ALT_ERROR
#endif
#endif
#if (0 == 2)
#ifndef MX_PWM_TRIS2a
#pragma error PWM component error (using alternative, but no MX_PWM_TRIS2a)
#define MX_PWM_ALT_ERROR
#endif
#ifndef MX_PWM_2a
#pragma error PWM component error (using alternative, but no MX_PWM_2a)
#define MX_PWM_ALT_ERROR
#endif
#endif
#endif
#ifdef MX_PWM
pr2 = 249;
t2con = 0x04;
#if (MX_PWM_CNT >= 1)
if (nIdx == 1)
{
ccp1con = 0x0C;
#if (0 == 1)
#ifndef MX_PWM_ALT_ERROR
clear_bit(MX_PWM_TRIS1a, MX_PWM_1a);
#endif
#else
clear_bit(MX_PWM_TRIS1, MX_PWM_1);
#endif
}
#endif
#if (MX_PWM_CNT >= 2)
if (nIdx == 2)
{
ccp2con = 0x0C;
#if (0 == 2)
#ifndef MX_PWM_ALT_ERROR
clear_bit(MX_PWM_TRIS2a, MX_PWM_2a);
#endif
#else
clear_bit(MX_PWM_TRIS2, MX_PWM_2);
#endif
}
#endif
#endif
#ifdef MX_PWM_ALT_ERROR
#undef MX_PWM_ALT_ERROR
#endif
}
void FCD_PWM0_Disable(char nIdx)
{
//error checking
#ifndef MX_PWM
#warning "This chip does not have PWM capability"
#endif
#ifdef MX_PWM
#if (MX_PWM_CNT >= 1)
if (nIdx == 1)
{
ccp1con = 0x00;
}
#endif
#if (MX_PWM_CNT >= 2)
if (nIdx == 2)
{
ccp2con = 0x00;
}
#endif
#endif
}
void FCD_PWM0_SetDutyCycle(char nIdx, char nDuty)
{
//error checking
#ifndef MX_PWM
#warning "This chip does not have PWM capability"
#endif
#ifdef MX_PWM
#if (MX_PWM_CNT >= 1)
if (nIdx == 1)
{
ccpr1l = nDuty;
}
#endif
#if (MX_PWM_CNT >= 2)
if (nIdx == 2)
{
ccpr2l = nDuty;
}
#endif
#endif
}
void FCD_PWM0_ChangePeriod(char nPeriodVal, char nPrescalerVal)
{
//error checking
#ifndef MX_PWM
#warning "This chip does not have PWM capability"
#endif
#ifdef MX_PWM
pr2 = nPeriodVal;
switch (nPrescalerVal)
{
case 1:
t2con = 0x04;
break;
case 4:
t2con = 0x05;
break;
case 16:
t2con = 0x06;
break;
}
#endif
I tried checking the box "use alternative pin" but it does not solve the problem.
How can I correct this?
Thanks in advance.