首要阐明:开发环境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 }
仿制代码