【中科昊芯Core_DSC280025C开发板试用体验】---模拟SPI及定时器的应用 - RISC-V MCU技术社区 - 电子技术论坛 - 广受欢迎的专业电子论坛
分享 收藏 返回

[文章]

【中科昊芯Core_DSC280025C开发板试用体验】---模拟SPI及定时器的应用

0219adee25a0b97f350354143ec04d59

前言
     早就听说中科昊芯是一家专注于数字信号处理器(DSP)领域的创新企业,其产品在工业控制、新能源汽车、光伏储能等领域有广泛应用。于是抱着试试看的心理申请了中科昊芯Core_DSC280025C开发板,没想到竟然通过了,收到开发板心里很是激动,红色的开发板和米黄色的仿真器各有一个彩色包装盒,从这里可以看出厂方很大气,仿真器做的也很大气。

开发板及单片机简介
    Core_DSC280025C核心板使用了昊芯HXS320F28025C RISC-VDSP芯片,该芯片集成了吴芯自主研发的H28x内核。核心板包括:14针的下载、调试接口、供电电源接口、复位、指示灯,板载一个按键,2个LED,以及两侧的对外扩展PIN脚等,除JTAG等IO外,所有外设IO全部引出,开发者可通过杜邦跳线进行功能验证,便于进行不同应用开发。
     IO口引出这一点有点像Arduino,方便开发者使用,但习惯于用51单片机写流水灯这类程序的初学者可能不太习惯,随着不断的使用,你会习惯这种用法的。
    开心归开心,学习一门新技术可不是一件容易的事情,花了近半个月的时间研究这款开发版,才初步有进展,能点亮LED,会使用按键中断,可以用模拟SPI驱动74HC595,会定时器的最简单应用,能驱动8位数码管。笔者参考厂家的例程,学习了定时器的用法,并参考STM32单片机的资料,编写了定时器计时,用软件模拟SPI驱动数码管显示程序,代码如下。
程序
   程序的编写要借助厂方的例程模板。
  1、主函数
  1. //min.c
  2. /******************************************************************
  3. 文 档 名:       HX_DSC280025_CPUtiMER
  4. 开 发 环 境:  Haawking IDE V2.3.10Pre
  5. 开 发 板:
  6. D S P:          DSC280025
  7. 使 用 库:
  8. 作     用:      定时器0中断秒计时,74HC595驱动8位数码管的段码,模拟SPI驱动,
  9.                   扫描位码经PNP管倒相驱动,从87650000秒开始显示,后4位为秒加1计数,满
  10.                   10000秒,后四位清0,主程序扫描显示
  11. 硬件:         //GPIO0接595的Pin_14数据
  12.                 //GPIO1接595的Pin_11移位脉冲
  13.                 //GPIO2接595的Pin_12锁存,并出
  14.                 //74HC595的PIN_10接电源
  15.                 //GPIO4~GPIO11驱动位码
  16. 说     明:      FLASH工程
  17. -------------------------- 例程使用说明 --------------------------
  18. 功能描述:芯片主频160MHz,定时器中断触发
  19. 版 本:      moni_SPI_2
  20.               与moni_SPI_1比较,定义了timer.h和timer.c文件,使主程序代码精简了
  21. 时 间:      2025年7月10日
  22. 作 者:
  23. @ mail:
  24. ******************************************************************/
  25. //
  26. // Included Files
  27. //
  28. #include "driverlib.h"
  29. #include "device.h"
  30. #include
  31. #include "IQmathLib.h"
  32. #include "hx_intrinsics.h"
  33. #include "driverlib.h"
  34. #include "device.h"
  35. #include "hx_fintdiv.h"
  36. #include "moni_SPI.h"         //自定义的模拟SPI头文件
  37. #include "timer.h"           //自定义的模拟timer头文件
  38. //0~9,熄灭共阳极数码管字段码
  39. unsigned char disp[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff};
  40. unsigned char buff[8]={1,2,3,4,5,6,7,8};        //显示缓冲
  41. unsigned int t0_sec = 0;                  //timer0中断次数,秒计时
  42. //unsigned int cnt = 0;
  43. //声明3个定时器中断次数
  44. uint16_t cpuTimer0IntCount;      //定时器用的变量为何不能放timer.h定义???
  45. uint16_t cpuTimer1IntCount;
  46. uint16_t cpuTimer2IntCount;
  47. //=============分离变量=================
  48. void fenli_data(unsigned int data)
  49. {
  50.     unsigned char i;
  51.     for(i=0;i<4;i++)              //共4位数码
  52.     {
  53.                  buff[i] = data % 10;         //先分离个位
  54.                 data /= 10;
  55.         }
  56.         /******************
  57.         //采用4位显示,高位为0,不点亮
  58.         if(0 == buff[3])              //如果千位为0
  59.         {
  60.           buff[3] = 10;               //千位不显示
  61.           if(0 == buff[2])            //如果百位为0
  62.           {
  63.              buff[2] = 10;            //百位不显示
  64.                  if(0 == buff[1])          //如果十位为0
  65.                buff[1] = 10;          //十位不显示
  66.           }
  67.         }
  68.          ******************/
  69. }
  70. void SEG_dit_Config(void)                      //8个扫描位初始化
  71. {
  72.     unsigned char x;
  73.     GPIO_setPinConfig(GPIO_4_GPIO4);              //在gpio.h声明,在gpio.c中定义
  74.     GPIO_setPinConfig(GPIO_5_GPIO5);              //在gpio.h声明,在gpio.c中定义
  75.     GPIO_setPinConfig(GPIO_6_GPIO6);              //在gpio.h声明,在gpio.c中定义
  76.     GPIO_setPinConfig(GPIO_7_GPIO7);              //在gpio.h声明,在gpio.c中定义
  77.     GPIO_setPinConfig(GPIO_8_GPIO8);              //在gpio.h声明,在gpio.c中定义
  78.     GPIO_setPinConfig(GPIO_9_GPIO9);              //在gpio.h声明,在gpio.c中定义
  79.     GPIO_setPinConfig(GPIO_10_GPIO10);              //在gpio.h声明,在gpio.c中定义
  80.     GPIO_setPinConfig(GPIO_11_GPIO11);              //在gpio.h声明,在gpio.c中定义
  81.     for(x=4;x<12;x++)                              //IO.04~IO.11的设置
  82.             {
  83.            GPIO_setDirectionMode(x, GPIO_DIR_MODE_OUT);  //在gpio.h声明,在gpio.c中定义
  84.            GPIO_setPadConfig(x, GPIO_PIN_TYPE_PULLUP);   //在gpio.h声明,在gpio.c中定义
  85.            GPIO_setQualificationMode(x, GPIO_QUAL_SYNC);  //在gpio.h声明,在gpio.c中定义
  86.             }
  87. }
  88. int main(void)
  89. {
  90.         unsigned char x,y;
  91.     Device_init();            //device文件夹下device.c里定义
  92.     /* 模拟SPI端口初始化 */
  93.         moni_SPI_Config();
  94.    //扫描位初始化
  95.         SEG_dit_Config();
  96.     /*GPIO配置,用于显示中断状态*/
  97.     GPIO_config();
  98.     /*初始化PIE与清PIE寄存器,关CPU中断*/
  99.     Interrupt_initModule();
  100.     /*初始化中断向量表*/
  101.     Interrupt_initVectorTable();
  102.     timer_ISR_peizhi( );         //定时器配置
  103.     /*打开全局中断*/
  104.     EINT;
  105.         while (1)
  106.                 //IO011~IO4自左向右接数码管扫描位1~8,倒相,段码74Hc595驱动
  107.         {
  108.                 fenli_data(t0_sec);             //把秒分离填充到右边4位显示缓冲区
  109.         for(y = 0; y < 30; y++)         //刷新扫描30次,可以480ms刷新一次数据
  110.                 {for(x = 0; x < 8; x++)         //8个数码管动态显示
  111.                 {
  112.                          hc595_display(disp[buff[7-x]]);       //模拟SPI发送函数,发送段码
  113.                          switch(x)                             //扫描位,显示清晰
  114.                          {
  115.                          case 0:
  116.                                  GPIO_writePin(4,0);                 //开通扫描位,倒相
  117.                                  DEVICE_DELAY_US(2000);              //延时2ms
  118.                                  GPIO_writePin(4,1);                 //熄灭扫描位
  119.                                  break;
  120.                          case 1:
  121.                                  GPIO_writePin(5,0);               //开通扫描位,倒相
  122.                                  DEVICE_DELAY_US(2000);            //延时2ms
  123.                                  GPIO_writePin(5,1);               //熄灭扫描位
  124.                                  break;
  125.                          case 2:
  126.                                  GPIO_writePin(6,0);               //开通扫描位,倒相
  127.                                  DEVICE_DELAY_US(2000);            //延时2ms
  128.                                  GPIO_writePin(6,1);               //熄灭扫描位
  129.                                  break;
  130.                          case 3:
  131.                                  GPIO_writePin(7,0);                //开通扫描位,倒相
  132.                                  DEVICE_DELAY_US(2000);            //延时2ms
  133.                                  GPIO_writePin(7,1);               //熄灭扫描位
  134.                                  break;
  135.                          case 4:
  136.                                  GPIO_writePin(8,0);               //开通扫描位,倒相
  137.                                  DEVICE_DELAY_US(2000);            //延时2ms
  138.                                  GPIO_writePin(8,1);               //熄灭扫描位
  139.                                  break;
  140.                          case 5:
  141.                                  GPIO_writePin(9,0);            //开通扫描位,倒相
  142.                                  DEVICE_DELAY_US(2000);          //延时2ms
  143.                                  GPIO_writePin(9,1);            //熄灭扫描位
  144.                                  break;
  145.                          case 6:
  146.                                  GPIO_writePin(10,0);           //开通扫描位,倒相
  147.                                  DEVICE_DELAY_US(2000);         //延时2ms
  148.                                  GPIO_writePin(10,1);           //熄灭扫描位
  149.                                  break;
  150.                          case 7:
  151.                                  GPIO_writePin(11,0);            //开通扫描位,倒相
  152.                                  DEVICE_DELAY_US(2000);         //延时2ms
  153.                                  GPIO_writePin(11,1);           //熄灭扫描位
  154.                                  break;
  155.                          }
  156.                 }
  157.                 /*****************
  158.                 {    //类似这样的代码共8组,显示时最左边的那位不该亮的段也有点亮,即消隐不良
  159.                          //hc595_display(disp[10]);          //清除段码,为何不清屏也行
  160.                          hc595_display(disp[buff[0]]);       //模拟SPI发送函数,发送段码
  161.                          GPIO_writePin(4,1);                 //熄灭
  162.                          GPIO_writePin(4,0);
  163.                          GPIO_writePin(5,1);
  164.                          GPIO_writePin(6,1);
  165.                          GPIO_writePin(7,1);
  166.                          GPIO_writePin(8,1);
  167.                          GPIO_writePin(9,1);
  168.                          GPIO_writePin(10,1);
  169.                          GPIO_writePin(11,1);
  170.                          DEVICE_DELAY_US(3000);              //延时1ms
  171.                 }
  172.          ***********************************************/
  173.                 }
  174.         }
  175. }
2、moni_SPI.c
  1. /*
  2. * moni_SPI.c
  3. *
  4. *  Created on: 2025年7月10日
  5. *      Author: 于
  6. */
  7. #include "moni_SPI.h"
  8. #include "system.h"
  9. //74HC595的Pin_10接VCC
  10. #define HC595_SDA_PIN   0           //GPIO0接595的Pin_14数据
  11. #define HC595_SFT_PIN   1          //GPIO1接595的Pin_11移位脉冲
  12. #define HC595_LCK_PIN   2          //GPIO2接595的Pin_8锁存,并出
  13. #define HC595_SDA_1        GPIO_writePin(HC595_SDA_PIN,1 )
  14. #define HC595_SDA_0        GPIO_writePin(HC595_SDA_PIN,0)
  15. #define HC595_SFT_1        GPIO_writePin(HC595_SFT_PIN ,1 )
  16. #define HC595_SFT_0        GPIO_writePin(HC595_SFT_PIN ,0 )
  17. #define HC595_LCK_1        GPIO_writePin(HC595_LCK_PIN,1 )
  18. #define HC595_LCK_0        GPIO_writePin(HC595_LCK_PIN,0 )
  19. void         moni_SPI_Config(void)
  20. {
  21.     GPIO_setPinConfig(GPIO_0_GPIO0);              //在gpio.h声明,在gpio.c中定义
  22.     GPIO_setDirectionMode(0, GPIO_DIR_MODE_OUT);  //在gpio.h声明,在gpio.c中定义
  23.     GPIO_setPadConfig(0, GPIO_PIN_TYPE_PULLUP);   //在gpio.h声明,在gpio.c中定义
  24.     GPIO_setQualificationMode(0, GPIO_QUAL_SYNC);  //在gpio.h声明,在gpio.c中定义
  25.     GPIO_setPinConfig(GPIO_1_GPIO1);              //在gpio.h声明,在gpio.c中定义
  26.     GPIO_setDirectionMode(1, GPIO_DIR_MODE_OUT);  //在gpio.h声明,在gpio.c中定义
  27.     GPIO_setPadConfig(1, GPIO_PIN_TYPE_PULLUP); //在gpio.h声明,在gpio.c中定义
  28.     GPIO_setQualificationMode(1, GPIO_QUAL_SYNC);  //在gpio.h声明,在gpio.c中定义
  29.     GPIO_setPinConfig(GPIO_2_GPIO2);              //在gpio.h声明,在gpio.c中定义
  30.     GPIO_setDirectionMode(2, GPIO_DIR_MODE_OUT);  //在gpio.h声明,在gpio.c中定义
  31.     GPIO_setPadConfig(2, GPIO_PIN_TYPE_PULLUP);   //在gpio.h声明,在gpio.c中定义
  32.     GPIO_setQualificationMode(2, GPIO_QUAL_SYNC);  //在gpio.h声明,在gpio.c中定义
  33. }
  34. //系统时钟24MHZ
  35. void hc595_display(unsigned char dat)     //模拟SPI发送函数
  36. {
  37.         unsigned char i=0;
  38.    for(i=0; i<8; i++)
  39.    {
  40.      if((dat&0x80) == 0)       //发送高位
  41.        HC595_SDA_0;
  42.      else
  43.        HC595_SDA_1;
  44.      dat <<= 1;          //次高位移至高位
  45.                  //HC595_SFT_0;       //移位时钟拉低
  46.      //DEVICE_DELAY_US(1);          //延时有必要可加长
  47.      HC595_SFT_1;           //移位时钟上升沿时,数据移入595
  48.      DEVICE_DELAY_US(1);     //延时1us
  49.      HC595_SFT_0;
  50.      DEVICE_DELAY_US(1);     //延时1us
  51.    }
  52.    //HC595_LCK_0;
  53.    //DEVICE_DELAY_US(1);     //延时1us
  54.    HC595_LCK_1;      //上升沿将数据送到输出锁存器
  55.    DEVICE_DELAY_US(1);     //延时1us
  56.    HC595_LCK_0;
  57.    DEVICE_DELAY_US(1);     //延时1us
  58. }
3、moni_SPI.h
  1. /*
  2. * moni_SPI.h
  3. *
  4. *  Created on: 2025年7月10日
  5. *      Author: 于
  6. */
  7. #ifndef SRC_MONI_SPI_H_
  8. #define SRC_MONI_SPI_H_
  9. void moni_SPI_Config(void);        //模拟SPI初始化
  10. void hc595_display(unsigned char  dat);       //模拟SPI发送函数
  11. #endif /* SRC_MONI_SPI_H_ */
4、system.h
  1. /*
  2. * system.h
  3. *
  4. *  Created on: 2025年7月10日
  5. *      Author: 于
  6. */
  7. #ifndef SRC_SYSTEM_H_
  8. #define SRC_SYSTEM_H_
  9. #include "driverlib.h"
  10. #include "device.h"
  11. #endif /* SRC_SYSTEM_H_ */
5、timer.c
  1. /*
  2. * timer.c
  3. *
  4. *  Created on: 2025年7月12日
  5. *      Author: 于
  6. */
  7. #include "timer.h"
  8. //声明3个定时器中断次数,这三个变量main.c中不用,可以只在此声明
  9. extern uint16_t cpuTimer0IntCount;      //定时器用的变量为何不能放timer.h定义???
  10. extern uint16_t cpuTimer1IntCount;
  11. extern uint16_t cpuTimer2IntCount;
  12. //
  13. // initCPUTimers - This function initializes all three CPU timers
  14. // to a known state.
  15. //
  16. void initCPUTimers(void)
  17. {
  18.     /*时钟周期初始化,配置成最大值*/
  19.     CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
  20.     CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
  21.     CPUTimer_setPeriod(CPUTIMER2_BASE, 0xFFFFFFFF);
  22.     /*时钟周期分频配置:基地址CPUTIMERx_BASE,n+1分频*/
  23.     CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
  24.     CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
  25.     CPUTimer_setPreScaler(CPUTIMER2_BASE, 0);
  26.     /*CpuTimer定时器暂停,便于配置:基地址CPUTIMERx_BASE*/
  27.     CPUTimer_stopTimer(CPUTIMER0_BASE);
  28.     CPUTimer_stopTimer(CPUTIMER1_BASE);
  29.     CPUTimer_stopTimer(CPUTIMER2_BASE);
  30.     /*CpuTimer定时器暂停,便于配置:基地址CPUTIMERx_BASE*/
  31.     CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
  32.     CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
  33.     CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);
  34.     /*重置定时器CpuTimer定时器中断计数*/
  35.     cpuTimer0IntCount = 0;
  36.     cpuTimer1IntCount = 0;
  37.     cpuTimer2IntCount = 0;
  38. }
  39. //
  40. // configCPUTimer - This function initializes the selected timer to the
  41. // period specified by the "freq" and "period" parameters. The "freq" is
  42. // entered as Hz and the period in uSeconds. The timer is held in the stopped
  43. // state after configuration.
  44. //
  45. void configCPUTimer(uint32_t cpuTimer, float freq, float period)
  46. {
  47.     uint32_t temp;
  48.     //
  49.     // Initialize timer period:
  50.     //
  51.     temp = (uint32_t)((freq / 1000000) * period);
  52.     CPUTimer_setPeriod(cpuTimer, temp);
  53.     //
  54.     // Set pre-scale counter to divide by 1 (SYSCLKOUT):
  55.     //
  56.     CPUTimer_setPreScaler(cpuTimer, 0);
  57.     //
  58.     // Initializes timer control register. The timer is stopped, reloaded,
  59.     // free run disabled, and interrupt enabled.
  60.     // Additionally, the free and soft bits are set
  61.     //
  62.     CPUTimer_stopTimer(cpuTimer);
  63.     CPUTimer_reloadTimerCounter(cpuTimer);
  64.     CPUTimer_setEmulationMode(cpuTimer,
  65.                               CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
  66.     CPUTimer_enableInterrupt(cpuTimer);
  67.     //
  68.     // Resets interrupt counters for the three cpuTimers
  69.     //
  70.     if (cpuTimer == CPUTIMER0_BASE)
  71.     {
  72.         cpuTimer0IntCount = 0;
  73.     }
  74.     else if(cpuTimer == CPUTIMER1_BASE)
  75.     {
  76.         cpuTimer1IntCount = 0;
  77.     }
  78.     else if(cpuTimer == CPUTIMER2_BASE)
  79.     {
  80.         cpuTimer2IntCount = 0;
  81.     }
  82. }
  83. //==========================================================
  84. //定时器配置
  85. void timer_ISR_peizhi(void)
  86. {
  87.     /*初始化定时器时钟cpuTimer*/
  88.     initCPUTimers();
  89.         /*配置定时器时钟cpuTimer:基地址CPUTIMERx_BASE,频率MHz,周期值us*/
  90.     configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ, 1000000);    //1s
  91.     configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 2000000);    //2s
  92.     configCPUTimer(CPUTIMER2_BASE, DEVICE_SYSCLK_FREQ, 4000000);    //4s
  93.     /*定时器时钟cpuTimer使能:基地址CPUTIMERx_BASE*/
  94.     CPUTimer_enableInterrupt(CPUTIMER0_BASE);
  95.     CPUTimer_enableInterrupt(CPUTIMER1_BASE);
  96.     CPUTimer_enableInterrupt(CPUTIMER2_BASE);
  97.     /*cpuTimer相应的定时器时钟PIE与CPU中断使能:中断INT_TIMERx*/
  98.     Interrupt_enable(INT_TIMER0);
  99.     Interrupt_enable(INT_TIMER1);
  100.     Interrupt_enable(INT_TIMER2);
  101.     /*cpuTimer定时器启动:基地址CPUTIMERx_BASE*/
  102.     CPUTimer_startTimer(CPUTIMER0_BASE);
  103.     CPUTimer_startTimer(CPUTIMER1_BASE);
  104.     CPUTimer_startTimer(CPUTIMER2_BASE);
  105.     /*中断入口INT_TIMER0指向相应中断服务程序,执行cpuTimer0ISR*/
  106.     Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
  107.     /*中断入口INT_TIMER1指向相应中断服务程序,执行cpuTimer1ISR*/
  108.     Interrupt_register(INT_TIMER1, &cpuTimer1ISR);
  109.     /*中断入口INT_TIMER2指向相应中断服务程序,执行cpuTimer2ISR*/
  110.     Interrupt_register(INT_TIMER2, &cpuTimer2ISR);
  111. }
  112. //==========================================================
  113. //
  114. // cpuTimer0ISR - Counter for CpuTimer0
  115. //
  116. extern unsigned int t0_sec;                  //timer0中断次数,秒计时
  117. __interrupt void cpuTimer0ISR(void)
  118. {
  119.     cpuTimer0IntCount++;
  120. //    /*GPIO31翻转闪灯,每进一次中断,翻转一次*/
  121.     //GPIO_togglePin(31);
  122.     t0_sec++;
  123.     if(10000 == t0_sec)
  124.           t0_sec = 0;
  125.     //
  126.     // Acknowledge this interrupt to receive more interrupts from group 1
  127.     //
  128.     Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
  129. }
  130. //
  131. // cpuTimer1ISR - Counter for CpuTimer1
  132. //
  133. __interrupt void cpuTimer1ISR(void)
  134. {
  135.     cpuTimer1IntCount++;
  136. //    /*GPIO34翻转闪灯,每进一次中断,翻转一次*/
  137.     //GPIO_togglePin(34);
  138. }
  139. //
  140. // cpuTimer2ISR - Counter for CpuTimer2
  141. //
  142. __interrupt void cpuTimer2ISR(void)
  143. {
  144.     cpuTimer2IntCount++;
  145. //    /*GPIO31与GPIO34翻转闪灯,每进一次中断,翻转一次*/
  146.    //GPIO_togglePin(31);
  147.   //GPIO_togglePin(34);
  148. }
  149. void GPIO_config(void)           //普通IO配置
  150. {
  151.     EALLOW;
  152.     /*GPIO31的IO功能配置*/
  153.     GPIO_setPinConfig(GPIO_31_GPIO31);
  154.     /*GPIO31的IO方向配置:GPIO_DIR_MODE_OUT输出,GPIO_DIR_MODE_IN输入*/
  155.     GPIO_setDirectionMode(31, GPIO_DIR_MODE_OUT);
  156.     /*GPIO31的上拉翻转配置:
  157.      * GPIO_PIN_TYE_STD上拉翻转输出或浮点输入,GPIO_PIN_TYPE_PULLUP-上拉翻转输入
  158.      * GPIO_PIN_TYPE_INVERT翻转极性输入,GPIO_PIN_TYPE_OD开漏输出*/
  159.     GPIO_setPadConfig(31, GPIO_PIN_TYPE_STD);
  160.     /*GPIO31的采样配置:GPIO_QUAL_SYNC同步采样,GPIO_QUAL_3SAMPLE-3采样
  161.      * GPIO_QUAL_6SAMPLE-6采样,GPIO_QUAL_ASYNC异步采样*/
  162.     GPIO_setQualificationMode(31, GPIO_QUAL_SYNC);
  163.     GPIO_setPinConfig(GPIO_34_GPIO34);
  164.    GPIO_setDirectionMode(34, GPIO_DIR_MODE_OUT);
  165.     GPIO_setPadConfig(34, GPIO_PIN_TYPE_STD);
  166.     GPIO_setQualificationMode(34, GPIO_QUAL_SYNC);
  167.     EDIS;
  168. }
  169. //
  170. // End of File
  171. //
6.timer.h
  1. /*
  2. * timer.h
  3. *
  4. *  Created on: 2025年7月12日
  5. *      Author: 于
  6. */
  7. #ifndef SRC_TIMER_H_
  8. #define SRC_TIMER_H_
  9. #include "driverlib.h"
  10. #include "device.h"
  11. //
  12. // Globals
  13. //
  14. //
  15. // Function Prototypes
  16. //
  17. __interrupt void cpuTimer0ISR(void);
  18. __interrupt void cpuTimer1ISR(void);
  19. __interrupt void cpuTimer2ISR(void);
  20. void initCPUTimers(void);
  21. void configCPUTimer(uint32_t, float, float);
  22. void GPIO_config(void);                       //普通IO配置
  23. //uint16_t  bss;                     //为何不屏蔽此句会出错?h文件里不能声明变量?
  24. void initCPUTimers(void);
  25. void configCPUTimer(uint32_t cpuTimer, float freq, float period);
  26. void timer_ISR_peizhi(void);        //定时器配置
  27. #endif /* SRC_TIMER_H_ */





  • 反.jpg
  • 开发版.png

更多回帖

×
发帖