⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer1_isr.c

📁 基于Cortex-M3的全自动焊接机
💻 C
字号:
#include "hw_types.h"
#include "hw_memmap.h"
#include  <hw_timer.h>
#include  <timer.h>
#include  <hw_ints.h>
#include  <interrupt.h>
#include "uart_servo_485.h"
#include "sysclock_init.h"
#include "deal_rec_data.h"
#include  "LM3S-UART0.H"

#include "define.h"
void timer1_init(void)
{
    SysCtlPeriEnable(SYSCTL_PERIPH_TIMER1);                     //  使能定时器模块
    TimerConfigure(TIMER1_BASE , TIMER_CFG_32_BIT_PER);         //  配置定时器为32位周期触发定时器
    IntEnable(INT_TIMER1A);                                     //  使能定时器中断
}
void start_timer1(unsigned char uc_delay)//定时uc_delay ms
{
    TimerDisable(TIMER1_BASE , TIMER_A);
    TimerLoadSet(TIMER1_BASE , TIMER_A , (TheSysClock*uc_delay)/1000);          
    TimerIntEnable(TIMER1_BASE , TIMER_TIMA_TIMEOUT);           //  使能定时器超时中断
    TimerEnable(TIMER1_BASE , TIMER_A);
    IntEnable(INT_TIMER1A);
}
void stop_timer1(void)
{
    TimerDisable(TIMER1_BASE , TIMER_A);
    TimerIntDisable(TIMER1_BASE , TIMER_TIMA_TIMEOUT);
    IntDisable(INT_TIMER1A); //彻底停止中断进入
    
}

void timer1_isr(void)
{
    
    unsigned long  ulStatus;

    ulStatus  =  TimerIntStatus(TIMER1_BASE , true);            //  读取中断状态
    TimerIntClear(TIMER1_BASE , ulStatus);                      //  清除中断状态,重要!

    if(look_up())//这里避免出现第一个if和最下面的eles配对
    {
        exchange_485_send();  
        uart0FIFOFill();//发送缓存数据(给执行机构串口)
        exchange_rec();//准备转为接收状态的预先动作
    }
    else
    {
        exchange_485_recv();//等待30ms将当前数据发送完
        stop_timer1();
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -