酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

1. 修改程序,使得led 灯闪烁循环为中速→慢速→快速; 2. 修改程序,使闪烁顺序为d14灯中速闪烁4次→d12慢速闪烁1次→d10 快速闪烁1次,依次循环。 d14gpio口为68,d12gpio口为66,d10gpio口为64。 #include "dsp2833x_device.h" // dsp2833x headerfile include file #include "dsp2833x_examples.h" // dsp2833x examples include file volatile unsigned int timer_int_cnt; // prototype statements for functions found within this file. interrupt void cpu_timer0_isr(void); interrupt void cpu_timer1_isr(void); interrupt void cpu_timer2_isr(void); void gpio

_init(void); // Main Program void main(void) { // Initialize System Control: InitSysCtrl(); // Initialize GPIO: gpio_init(); // Initialize Timer: InitCpuTimers(); // Configure CPU-Timer 0 to interrupt every 500 milliseconds: ConfigCpuTimer(&CpuTimer0, 150, 1000000); // Start CPU-Timer 0 StartCpuTimer0(); // Enable global Interrupts and higher priority real-time debug events: IER |= M_INT1; EINT; // Perform the first action immediately GpioDataRegs.GPBDAT.bit.GPIO68 = 1; // Main loop while(1) { if(timer_int_cnt % 4 == 0) // Every 2 seconds { // Toggle the GPIO68 LED GpioDataRegs.GPBTOGGLE.bit.GPIO68 = 1; } else if(timer_int_cnt % 6 == 0) // Every 3 seconds { // Toggle the GPIO66 LED GpioDataRegs.GPBTOGGLE.bit.GPIO66 = 1; } else if(timer_int_cnt % 8 == 0) // Every 4 seconds { // Toggle the GPIO64 LED GpioDataRegs.GPBTOGGLE.bit.GPIO64 = 1; } } } // Initialize GPIO void gpio_init(void) { // Init the GPIO pins for LEDs: EALLOW; GpioCtrlRegs.GPBDIR.bit.GPIO68 = 1; GpioCtrlRegs.GPBDIR.bit.GPIO66 = 1; GpioCtrlRegs.GPBDIR.bit.GPIO64 = 1; GpioDataRegs.GPBDAT.bit.GPIO68 = 0; GpioDataRegs.GPBDAT.bit.GPIO66 = 0; GpioDataRegs.GPBDAT.bit.GPIO64 = 0; EDIS; } // CPU Timer 0 Interrupt Service Routine interrupt void cpu_timer0_isr(void) { // Acknowledge the interrupt PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Increment the interrupt count timer_int_cnt++; } interrupt void cpu_timer1_isr(void) { // Acknowledge the interrupt PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Increment the interrupt count timer_int_cnt++; } interrupt void cpu_timer2_isr(void) { // Acknowledge the interrupt PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Increment the interrupt count timer_int_cnt++; } [2024-10-20 21:14:21 | AI写代码神器 | 1312点数解答]

相关提问