请高手帮忙看下是什么原因导致编译报错?
谢谢!
代码片段如下:
uint16 xdata PWM_Dutyfactor[8] _at_ 0x0740; //PWM占空比调节寄存器地址
/*****************************************************
*函数名称:void PWM_Dutyfactor_Init(PWM_Pin_TypeDef PWM_Pin,PWM_Direction_TypeDef PWM_Direction,uint16 PWM_Dutyfactor)
*函数功能:PWM占空比设置
*入口参数:PWM_Pin,PWM_Direction,PWM_Dutyfactor
*出口参数:void
*****************************************************/
void PWM_Dutyfactor_Init(PWM_Pin_TypeDef PWM_Pin,PWM_Direction_TypeDef PWM_Direction,uint16 PWM_Dutyfactor)
{
uint16 xdata PWMRD = 0x8000;
if(PWM_Direction == PWM_Direction_N)
{
PWMRD |= ((uint16)(1<<17));
}
else if(PWM_Direction == PWM_Direction_P)
{
PWMRD &= ~((uint16)(1<<17));
}
else
{
PWMRD &= ~((uint16)(1<<17));
}
PWMRD &= ~((uint16)0xC000); //第0~14位全置0
PWMRD |= ((uint16)(PWM_Dutyfactor & 0x0FFF)); //PWM_Dutyfactor的第13~16位全置0,然后与PWMRD进行位或运算
switch(PWM_Pin)
{
case PWM_Pin_40: PWM_Dutyfactor[0] = PWMRD; break;
case PWM_Pin_41: PWM_Dutyfactor[1] = PWMRD; break;
case PWM_Pin_42: PWM_Dutyfactor[2] = PWMRD; break;
case PWM_Pin_43: PWM_Dutyfactor[3] = PWMRD; break;
case PWM_Pin_50: PWM_Dutyfactor[4] = PWMRD; break;
case PWM_Pin_51: PWM_Dutyfactor[5] = PWMRD; break;
case PWM_Pin_52: PWM_Dutyfactor[6] = PWMRD; break;
case PWM_Pin_53: PWM_Dutyfactor[7] = PWMRD; break;
default: break;
}
}
编译错误输出如下:
Rebuild target 'Target 1'
assembling STARTUP.A51...
compiling main.c...
..\src\sc92f854x_pwm.c(92): error C216: subscript on non-array or too many dimensions
Target not created
|