问答

汇集网友智慧,解决技术难题

阔砸

TA的家园币:90  

  • 辉芒FT60E121-SOP8 中断问题

    PA5触发中断时理应只有BLUE_PIN(PA0)输出高电平,但实际情况也YELLOW_PIN(PA2)有输出,有没有大佬懂,帮帮小弟#include"SYSCFG.h"//***********************宏定义****************************#defineuncharunsignedcharuncharFCount;uncharReadAPin;#defineBLUE_PINPA0#defineWHITE_PINPA1#defineYELLOW_PINPA2//定义输出引脚#defineturn_signalPA5#definewidth_signalPA4volatileunsignedcharis_running=0;volatilefloatpwm_counter=0;#definePWM_PERIOD10//PWM周期,根据定时器频率调整volatilefloatpwm_blue_duty=0;//占空比volatilefloatpwm_white_duty=0;//占空比volatileunsignedintcycle_count=0;volatileunsignedintstep=10;intstep1=0;/*-------------------------------------------------*函数名:interruptISR*功能:中断处理*输入:无*输出:无--------------------------------------------------*/voidinterruptISR(void){if(PA5){YELLOW_PIN=1;BLUE_PIN=0;WHITE_PIN=0;}if(T0IE&&T0IF){T0IF=0;}if(TMR2IE&&TMR2IF){TMR2IF=0;if(pwm_counter>=PWM_PERIOD)pwm_counter=0;else{pwm_counter+=0.1;}if(pwm_blue_duty>PWM_PERIOD){pwm_blue_duty=0;}}}/*-------------------------------------------------*函数名:POWER_INITIAL*功能:上电系统初始化*输入:无*输出:无--------------------------------------------------*/voidPOWER_INITIAL(void){OSCCON=0B01110001;//IRCF=111=16MHz/2=8MHz,0.125usINTCON=0;//暂禁止所有中断PORTA=0B00000000;TRISA=0B00110000;//PA输入输出0-输出1-输入//PA4-OUTPORTC=0B00000000;TRISC=0B00000000;//PC输入输出0-输出1-输入WPUA=0B00110000;//PA端口上拉控制1-开上拉0-关上拉//开PA6上拉OPTION=0B00000000;//Bit3=0TMR0MODE,PS=000=TMR0Rate1:2PSRCA=0B11111111;//源电流设置最大PSRCC=0B11111111;PSINKA=0B11111111;//灌电流设置最大PSINKC=0B11111111;MSCON=0B001

    PWM 11 TI FT 辉芒 单片机

    2024-07-10 0