請問我現在使用GPIOC 做0 , 1輸出,
我在用keil C 軟體仿真LED1有輸出波形,但OUT1&OUT2沒有。
請問我的程序有設置錯嗎?
以下是我的程序
[mw_shl_code=c,true]#define LED1 PBout(12)
#define OUT1 PCout(0)
#define OUT2 PCout(1)
void OutputPin_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC,GPIO_Pin_All);
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_12);
}
void Cylinder_Init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
TIM_TimeBaseStructure.TIM_Period = 999;
TIM_TimeBaseStructure.TIM_Prescaler =71;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM4,TIM_IT_Update|TIM_IT_Trigger,ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//TIM_Cmd(TIM4, ENABLE);
}
void TIM4_IRQHandler(void)
{
if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM4, TIM_IT_Update );
CylinderCount++;
LED1=!LED1;
}
}
int main(void)
{
SystemInit();
delay_init(72);
NVIC_Configuration();
OutputPin_Init();
InputPin_Init();
Cylinder_Init();
delay_ms(10);
// Data_Init();
TIM_Cmd(TIM4, ENABLE);
while(StartCount!=EndCount||StartCount==0)
{
if(lSolenoidVSTB[1]==CylinderCount-1)
{
OUT1=1;
StartCount++;
}
if((lSolenoidVSTB[1]+lSolenoidVDB[1])==CylinderCount)
{
OUT1=0;
EndCount++;
}
if(lSolenoidVSTB[2]==CylinderCount-1)
{
OUT2=1;
StartCount++;
}
if((lSolenoidVSTB[2]+lSolenoidVDB[2])==CylinderCount-1)
{
OUT2=0;
EndCount++;
}
delay_ms(1);
}
TIM_Cmd(TIM4, DISABLE);
while(1){}[/mw_shl_code]
|