zoukankan      html  css  js  c++  java
  • DSP学习教程基于28335(一)

    首先说明:开发环境Manjaro linux,内核5.0,滚动升级版本,随时都是最新,CCS也是最新的CCv 8

      1 #include "DSP2833x_Device.h"     // 这是一个很重要的头文件,决定CPU类型,数据类型、asm宏指令,包含的所有的外设,外设的头文件和其他硬件的抽象头文件
      2 #include "DSP2833x_Examples.h"   // 该头文件是常用实现函数的文件包含
      3   6 //中断服务函数声明
      7 __interrupt void wakeint_isr(void);
      8 
      9 //声明全局变量
     12 Uint32 WakeCount;
     13 Uint32 LoopCount;
     14 
     15 //主函数
     18 void main(void)
     19 {
     20     // Step 1. 初始化系统控制:
     22     // 配置PLL,设置cpu时钟
     23     // 配置外设时钟
     24     // 配置看门狗 该函数在 DSP2833x_SysCtrl.c中.
     25     InitSysCtrl();                                  
     26 
     27     // Step 2. 初始化GPIO:
     29     // 该函数在 DSP2833x_Gpio.c .
     32     //InitGpio();   33 
     34     // Step 3. 初始化中断:
     36     // 禁止CPU中断,该函数在 DSP2833x_Device.h 38     DINT;
     39 
     40     // 禁止外设中断
     41     // 清理外设中断允许寄存器
     42     // 清理外设中断标志寄存器
     43     // 禁止CPU中断,设置允许中断位为0
     44     // 初始化外设中断向量表
     45     // 设置中断函数
     46     InitPieCtrl();
     47 
     48     //
     49     // Disable CPU interrupts and clear all CPU interrupt flags
     50     //
     51     IER = 0x0000;
     52     IFR = 0x0000;
     53 
     54     //
     55     // Initialize the PIE vector table with pointers to the shell Interrupt
     56     // Service Routines (ISR).
     57     // This will populate the entire table, even if the interrupt
     58     // is not used in this example.  This is useful for debug purposes.
     59     // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
     60     // This function is found in DSP2833x_PieVect.c.
     61     //
     62     InitPieVectTable();
     63 
     64     //
     65     // Interrupts that are used in this example are re-mapped to
     66     // ISR functions found within this file.
     67     //
     68     EALLOW;            // This is needed to write to EALLOW protected registers
     69     PieVectTable.WAKEINT = &wakeint_isr;
     70     EDIS;   // This is needed to disable write to EALLOW protected registers
     71 
     72     // Step 4. 初始化外设:
     74     // 该函数在 DSP2833x_InitPeripherals.c 中
     75     //
     76     //InitPeripherals(); // Not required for this example
     77 
     78     // Step 5. 用户自己的代码
     80     // Clear the counters
     84     //
     85     WakeCount = 0;      // Count interrupts
     86     LoopCount = 0;      // Count times through idle loop
     87 
     88     //
     89     // 将看门狗中断连接到PIE中断,该寄存器首SCM控制,使用特定的修改方式
     90     // Write to the whole SCSR register to avoid clearing WDOVERRIDE bit
     91     //
     92     EALLOW;
     93     SysCtrlRegs.SCSR = BIT1;
     94     EDIS;
     95 
     96     //
     97     // Enable WAKEINT in the PIE: Group 1 interrupt 8
     98     // Enable INT1 which is connected to WAKEINT:
     99     //
    100     PieCtrlRegs.PIECTRL.bit.ENPIE = 1;      // Enable the PIE block
    101     PieCtrlRegs.PIEIER1.bit.INTx8 = 1;      // Enable PIE Group 1 INT8
    102     IER |= M_INT1;                          // Enable CPU int1
    103     EINT;                                   // Enable Global Interrupts
    104 
    105     //
    106     // Reset the watchdog counter
    107     //
    108     ServiceDog();
    109 
    110     //
    111     // Enable the watchdog
    112     //
    113     EALLOW;
    114     SysCtrlRegs.WDCR = 0x0028;
    115     EDIS;
    116 
    117     //
    118     // Step 6. 函数执行环节
    119     //
    120     for(;;)
    121     {
    122         LoopCount++;
    123 
    124         //
    125         // Uncomment ServiceDog to just loop here
    126         // Comment ServiceDog to take the WAKEINT instead
    127         //
    128         //ServiceDog();
    129     }
    130 }
    131 
    132 // 中断函数
    133 // Step 7. Insert all local Interrupt Service Routines (ISRs) and functions 
    134 // here: If local ISRs are used, reassign vector addresses in vector table as
    135 // shown in Step 5
    136 //
    137 
    138 //
    139 // wakeint_isr -
    140 //
    141 __interrupt void
    142 wakeint_isr(void)
    143 {
    144     WakeCount++;
    145 
    146     //
    147     // Acknowledge this interrupt to get more from group 1
    148     //
    149     PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    150 }

    在我看来,这就是个看门狗6 + 1,通常包括ti的都把他们当成7个环节,但是作为中断函数更多的应该只是个附属品而已,我这样说也是可以的。

  • 相关阅读:
    ASP.NET SignalR 系列(九)之源码与总结
    ASP.NET SignalR 系列(八)之跨域推送
    ASP.NET SignalR 系列(七)之服务端触发推送
    ASP.NET SignalR 系列(六)之连接事件
    ASP.NET SignalR 系列(五)之群组推送
    ASP.NET SignalR 系列(四)之指定对象推送
    ASP.NET SignalR 系列(三)之代码实现
    ASP.NET SignalR 系列(二)之项目创建
    ASP.NET SignalR 系列(一)之SignalR介绍
    Splunk带来的好处
  • 原文地址:https://www.cnblogs.com/guochaoxxl/p/10556524.html
Copyright © 2011-2022 走看看