feat: 开启定时器和串口接收中断

This commit is contained in:
2024-04-13 01:28:34 +08:00
parent 28cd0d99a3
commit d90e5d0e61
7 changed files with 960 additions and 853 deletions

View File

@@ -20,9 +20,9 @@
</Mode> </Mode>
<Parameters> <Parameters>
<ParametersSub name="BaudRate" value="500"/> <ParametersSub name="BaudRate" value="500"/>
<ParametersSub name="Sample_Point" value="87.5"/> <ParametersSub name="Sample_Point" value="90.0"/>
<ParametersSub name="BaudRate_Division" value="30"/> <ParametersSub name="BaudRate_Division" value="24"/>
<ParametersSub name="BTS1" value="CAN_BTS1_6TQ"/> <ParametersSub name="BTS1" value="CAN_BTS1_8TQ"/>
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/> <ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/> <ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
</Parameters> </Parameters>
@@ -33,9 +33,9 @@
</Mode> </Mode>
<Parameters> <Parameters>
<ParametersSub name="BaudRate" value="500"/> <ParametersSub name="BaudRate" value="500"/>
<ParametersSub name="Sample_Point" value="87.5"/> <ParametersSub name="Sample_Point" value="90.0"/>
<ParametersSub name="BaudRate_Division" value="30"/> <ParametersSub name="BaudRate_Division" value="24"/>
<ParametersSub name="BTS1" value="CAN_BTS1_6TQ"/> <ParametersSub name="BTS1" value="CAN_BTS1_8TQ"/>
<ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/> <ParametersSub name="BTS2" value="CAN_BTS2_1TQ"/>
<ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/> <ParametersSub name="RSAW" value="CAN_RSAW_1TQ"/>
</Parameters> </Parameters>
@@ -71,11 +71,15 @@
<ParametersSub name="GeneralCallMode" value="FALSE"/> <ParametersSub name="GeneralCallMode" value="FALSE"/>
</Parameters> </Parameters>
</I2C2> </I2C2>
<PWC> <TMR6>
<Mode> <Mode>
<ModeSub name="Voltage-Monitoring" value="TRUE"/> <ModeSub name="Activated" value="TRUE"/>
</Mode> </Mode>
</PWC> <Parameters>
<ParametersSub name="DividerValue" value="4999"/>
<ParametersSub name="Period" value="47999"/>
</Parameters>
</TMR6>
<TMR8> <TMR8>
<Mode> <Mode>
<ModeSub name="Channel1 mode" value="Output_CH1"/> <ModeSub name="Channel1 mode" value="Output_CH1"/>
@@ -128,13 +132,14 @@
<I2C1_ERR_IRQHandler>0;0;0</I2C1_ERR_IRQHandler> <I2C1_ERR_IRQHandler>0;0;0</I2C1_ERR_IRQHandler>
<I2C2_EVT_IRQHandler>0;0;0</I2C2_EVT_IRQHandler> <I2C2_EVT_IRQHandler>0;0;0</I2C2_EVT_IRQHandler>
<I2C2_ERR_IRQHandler>0;0;0</I2C2_ERR_IRQHandler> <I2C2_ERR_IRQHandler>0;0;0</I2C2_ERR_IRQHandler>
<USART1_IRQHandler>0;0;0</USART1_IRQHandler> <USART1_IRQHandler>1;1;0</USART1_IRQHandler>
<USART2_IRQHandler>0;0;0</USART2_IRQHandler> <USART2_IRQHandler>1;1;0</USART2_IRQHandler>
<USART3_IRQHandler>0;0;0</USART3_IRQHandler> <USART3_IRQHandler>1;1;0</USART3_IRQHandler>
<TMR8_BRK_TMR12_IRQHandler>0;0;0</TMR8_BRK_TMR12_IRQHandler> <TMR8_BRK_TMR12_IRQHandler>0;0;0</TMR8_BRK_TMR12_IRQHandler>
<TMR8_OVF_TMR13_IRQHandler>0;0;0</TMR8_OVF_TMR13_IRQHandler> <TMR8_OVF_TMR13_IRQHandler>0;0;0</TMR8_OVF_TMR13_IRQHandler>
<TMR8_TRG_HALL_TMR14_IRQHandler>0;0;0</TMR8_TRG_HALL_TMR14_IRQHandler> <TMR8_TRG_HALL_TMR14_IRQHandler>0;0;0</TMR8_TRG_HALL_TMR14_IRQHandler>
<TMR8_CH_IRQHandler>0;0;0</TMR8_CH_IRQHandler> <TMR8_CH_IRQHandler>0;0;0</TMR8_CH_IRQHandler>
<TMR6_GLOBAL_IRQHandler>1;0;0</TMR6_GLOBAL_IRQHandler>
<CAN2_TX_IRQHandler>0;0;0</CAN2_TX_IRQHandler> <CAN2_TX_IRQHandler>0;0;0</CAN2_TX_IRQHandler>
<CAN2_RX0_IRQHandler>0;0;0</CAN2_RX0_IRQHandler> <CAN2_RX0_IRQHandler>0;0;0</CAN2_RX0_IRQHandler>
<CAN2_RX1_IRQHandler>0;0;0</CAN2_RX1_IRQHandler> <CAN2_RX1_IRQHandler>0;0;0</CAN2_RX1_IRQHandler>
@@ -205,9 +210,7 @@
<KeepUserCode>true</KeepUserCode> <KeepUserCode>true</KeepUserCode>
<MinHeapSize>0x200</MinHeapSize> <MinHeapSize>0x200</MinHeapSize>
<MinStackSize>0x400</MinStackSize> <MinStackSize>0x400</MinStackSize>
<UseFirmware>true</UseFirmware> <UseFirmware>false</UseFirmware>
<UseFirmwareZip>true</UseFirmwareZip> <PackageVersion></PackageVersion>
<FirmwarePath>C:/Users/ForgotDoge/Desktop/AT32_Work_Bench_V1.0.03/AT32F403A_407_Firmware_Library_V2.1.8.zip</FirmwarePath>
<FirmwareFolderPath></FirmwareFolderPath>
</ProjectInfomation> </ProjectInfomation>
</Root> </Root>

View File

@@ -61,7 +61,7 @@ extern "C" {
#define DEBUG_MODULE_ENABLED #define DEBUG_MODULE_ENABLED
/*#define DMA_MODULE_ENABLED----------------------*/ /*#define DMA_MODULE_ENABLED----------------------*/
/*#define EMAC_MODULE_ENABLED---------------------*/ /*#define EMAC_MODULE_ENABLED---------------------*/
#define EXINT_MODULE_ENABLED /*#define EXINT_MODULE_ENABLED--------------------*/
#define FLASH_MODULE_ENABLED #define FLASH_MODULE_ENABLED
#define GPIO_MODULE_ENABLED #define GPIO_MODULE_ENABLED
#define I2C_MODULE_ENABLED #define I2C_MODULE_ENABLED

View File

@@ -65,6 +65,10 @@ void SVC_Handler(void);
void DebugMon_Handler(void); void DebugMon_Handler(void);
void PendSV_Handler(void); void PendSV_Handler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void USART3_IRQHandler(void);
void TMR6_GLOBAL_IRQHandler(void);
/* add user code begin exported functions */ /* add user code begin exported functions */
/* add user code end exported functions */ /* add user code end exported functions */

View File

@@ -86,9 +86,6 @@ extern "C" {
/* init can2 function. */ /* init can2 function. */
void wk_can2_init(void); void wk_can2_init(void);
/* init pwc function. */
void wk_pwc_init(void);
/* init usart1 function. */ /* init usart1 function. */
void wk_usart1_init(void); void wk_usart1_init(void);
@@ -98,6 +95,9 @@ extern "C" {
/* init usart3 function. */ /* init usart3 function. */
void wk_usart3_init(void); void wk_usart3_init(void);
/* init tmr6 function. */
void wk_tmr6_init(void);
/* init tmr8 function. */ /* init tmr8 function. */
void wk_tmr8_init(void); void wk_tmr8_init(void);

View File

@@ -1,27 +1,27 @@
/* add user code begin Header */ /* add user code begin Header */
/** /**
************************************************************************** **************************************************************************
* @file at32f403a_407_int.c * @file at32f403a_407_int.c
* @brief main interrupt service routines. * @brief main interrupt service routines.
************************************************************************** **************************************************************************
* Copyright notice & Disclaimer * Copyright notice & Disclaimer
* *
* The software Board Support Package (BSP) that is made available to * The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery. * download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP * Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and * software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the * development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer. * software is governed by this copyright notice and the following disclaimer.
* *
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES, * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS, * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS, * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
* *
************************************************************************** **************************************************************************
*/ */
/* add user code end Header */ /* add user code end Header */
/* includes ------------------------------------------------------------------*/ /* includes ------------------------------------------------------------------*/
@@ -29,7 +29,7 @@
/* private includes ----------------------------------------------------------*/ /* private includes ----------------------------------------------------------*/
/* add user code begin private includes */ /* add user code begin private includes */
#include "by_debug.h"
/* add user code end private includes */ /* add user code end private includes */
/* private typedef -----------------------------------------------------------*/ /* private typedef -----------------------------------------------------------*/
@@ -68,140 +68,202 @@
/* add user code end external variables */ /* add user code end external variables */
/** /**
* @brief this function handles nmi exception. * @brief this function handles nmi exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void NMI_Handler(void) void NMI_Handler(void)
{ {
/* add user code begin NonMaskableInt_IRQ 0 */ /* add user code begin NonMaskableInt_IRQ 0 */
/* add user code end NonMaskableInt_IRQ 0 */ /* add user code end NonMaskableInt_IRQ 0 */
/* add user code begin NonMaskableInt_IRQ 1 */ /* add user code begin NonMaskableInt_IRQ 1 */
/* add user code end NonMaskableInt_IRQ 1 */ /* add user code end NonMaskableInt_IRQ 1 */
} }
/** /**
* @brief this function handles hard fault exception. * @brief this function handles hard fault exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void HardFault_Handler(void) void HardFault_Handler(void)
{ {
/* add user code begin HardFault_IRQ 0 */ /* add user code begin HardFault_IRQ 0 */
/* add user code end HardFault_IRQ 0 */ /* add user code end HardFault_IRQ 0 */
/* go to infinite loop when hard fault exception occurs */ /* go to infinite loop when hard fault exception occurs */
while (1) while (1) {
{ /* add user code begin W1_HardFault_IRQ 0 */
/* add user code begin W1_HardFault_IRQ 0 */
/* add user code end W1_HardFault_IRQ 0 */ /* add user code end W1_HardFault_IRQ 0 */
} }
} }
/** /**
* @brief this function handles memory manage exception. * @brief this function handles memory manage exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void MemManage_Handler(void) void MemManage_Handler(void)
{ {
/* add user code begin MemoryManagement_IRQ 0 */ /* add user code begin MemoryManagement_IRQ 0 */
/* add user code end MemoryManagement_IRQ 0 */ /* add user code end MemoryManagement_IRQ 0 */
/* go to infinite loop when memory manage exception occurs */ /* go to infinite loop when memory manage exception occurs */
while (1) while (1) {
{ /* add user code begin W1_MemoryManagement_IRQ 0 */
/* add user code begin W1_MemoryManagement_IRQ 0 */
/* add user code end W1_MemoryManagement_IRQ 0 */ /* add user code end W1_MemoryManagement_IRQ 0 */
} }
} }
/** /**
* @brief this function handles bus fault exception. * @brief this function handles bus fault exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void BusFault_Handler(void) void BusFault_Handler(void)
{ {
/* add user code begin BusFault_IRQ 0 */ /* add user code begin BusFault_IRQ 0 */
/* add user code end BusFault_IRQ 0 */ /* add user code end BusFault_IRQ 0 */
/* go to infinite loop when bus fault exception occurs */ /* go to infinite loop when bus fault exception occurs */
while (1) while (1) {
{ /* add user code begin W1_BusFault_IRQ 0 */
/* add user code begin W1_BusFault_IRQ 0 */
/* add user code end W1_BusFault_IRQ 0 */ /* add user code end W1_BusFault_IRQ 0 */
} }
} }
/** /**
* @brief this function handles usage fault exception. * @brief this function handles usage fault exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void UsageFault_Handler(void) void UsageFault_Handler(void)
{ {
/* add user code begin UsageFault_IRQ 0 */ /* add user code begin UsageFault_IRQ 0 */
/* add user code end UsageFault_IRQ 0 */ /* add user code end UsageFault_IRQ 0 */
/* go to infinite loop when usage fault exception occurs */ /* go to infinite loop when usage fault exception occurs */
while (1) while (1) {
{ /* add user code begin W1_UsageFault_IRQ 0 */
/* add user code begin W1_UsageFault_IRQ 0 */
/* add user code end W1_UsageFault_IRQ 0 */ /* add user code end W1_UsageFault_IRQ 0 */
} }
} }
/** /**
* @brief this function handles svcall exception. * @brief this function handles svcall exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void SVC_Handler(void) void SVC_Handler(void)
{ {
/* add user code begin SVCall_IRQ 0 */ /* add user code begin SVCall_IRQ 0 */
/* add user code end SVCall_IRQ 0 */ /* add user code end SVCall_IRQ 0 */
/* add user code begin SVCall_IRQ 1 */ /* add user code begin SVCall_IRQ 1 */
/* add user code end SVCall_IRQ 1 */ /* add user code end SVCall_IRQ 1 */
} }
/** /**
* @brief this function handles debug monitor exception. * @brief this function handles debug monitor exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void DebugMon_Handler(void) void DebugMon_Handler(void)
{ {
/* add user code begin DebugMonitor_IRQ 0 */ /* add user code begin DebugMonitor_IRQ 0 */
/* add user code end DebugMonitor_IRQ 0 */ /* add user code end DebugMonitor_IRQ 0 */
/* add user code begin DebugMonitor_IRQ 1 */ /* add user code begin DebugMonitor_IRQ 1 */
/* add user code end DebugMonitor_IRQ 1 */ /* add user code end DebugMonitor_IRQ 1 */
} }
/** /**
* @brief this function handles pendsv_handler exception. * @brief this function handles pendsv_handler exception.
* @param none * @param none
* @retval none * @retval none
*/ */
void PendSV_Handler(void) void PendSV_Handler(void)
{ {
/* add user code begin PendSV_IRQ 0 */ /* add user code begin PendSV_IRQ 0 */
/* add user code end PendSV_IRQ 0 */ /* add user code end PendSV_IRQ 0 */
/* add user code begin PendSV_IRQ 1 */ /* add user code begin PendSV_IRQ 1 */
/* add user code end PendSV_IRQ 1 */ /* add user code end PendSV_IRQ 1 */
}
/**
* @brief this function handles USART1 handler.
* @param none
* @retval none
*/
void USART1_IRQHandler(void)
{
/* add user code begin USART1_IRQ 0 */
/* add user code end USART1_IRQ 0 */
/* add user code begin USART1_IRQ 1 */
/* add user code end USART1_IRQ 1 */
}
/**
* @brief this function handles USART2 handler.
* @param none
* @retval none
*/
void USART2_IRQHandler(void)
{
/* add user code begin USART2_IRQ 0 */
if (SET == usart_flag_get(USART2, USART_RDBF_FLAG)) {
usart_data_receive(USART2);
usart_flag_clear(USART2, USART_RDBF_FLAG);
}
/* add user code end USART2_IRQ 0 */
/* add user code begin USART2_IRQ 1 */
/* add user code end USART2_IRQ 1 */
}
/**
* @brief this function handles USART3 handler.
* @param none
* @retval none
*/
void USART3_IRQHandler(void)
{
/* add user code begin USART3_IRQ 0 */
/* add user code end USART3_IRQ 0 */
/* add user code begin USART3_IRQ 1 */
/* add user code end USART3_IRQ 1 */
}
/**
* @brief this function handles TMR6 handler.
* @param none
* @retval none
*/
void TMR6_GLOBAL_IRQHandler(void)
{
/* add user code begin TMR6_GLOBAL_IRQ 0 */
static uint64_t i = 0;
if (SET == tmr_flag_get(TMR6, TMR_OVF_FLAG)) {
tmr_flag_clear(TMR6, TMR_OVF_FLAG);
}
/* add user code end TMR6_GLOBAL_IRQ 0 */
/* add user code begin TMR6_GLOBAL_IRQ 1 */
/* add user code end TMR6_GLOBAL_IRQ 1 */
} }
/* add user code begin 1 */ /* add user code begin 1 */

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,7 @@
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "at32f403a_407_wk_config.h" #include "at32f403a_407_wk_config.h"
/* private includes ----------------------------------------------------------*/ /* private includes ----------------------------------------------------------*/
/* add user code begin private includes */ /* add user code begin private includes */
#include "dwt_delay.h" #include "dwt_delay.h"
@@ -71,7 +72,7 @@
int main(void) int main(void)
{ {
/* add user code begin 1 */ /* add user code begin 1 */
by_debug_init();
/* add user code end 1 */ /* add user code end 1 */
/* system clock config. */ /* system clock config. */
@@ -83,9 +84,6 @@ int main(void)
/* init debug function. */ /* init debug function. */
wk_debug_config(); wk_debug_config();
/* init pwc function. */
wk_pwc_init();
/* nvic config. */ /* nvic config. */
wk_nvic_config(); wk_nvic_config();
@@ -107,6 +105,9 @@ int main(void)
/* init adc1 function. */ /* init adc1 function. */
wk_adc1_init(); wk_adc1_init();
/* init tmr6 function. */
wk_tmr6_init();
/* init tmr8 function. */ /* init tmr8 function. */
wk_tmr8_init(); wk_tmr8_init();
@@ -127,9 +128,9 @@ int main(void)
/* add user code begin 2 */ /* add user code begin 2 */
DWT_Init(); DWT_Init();
by_debug_init();
/* add user code end 2 */
lwprintf("init done!\r\n");
/* add user code end 2 */
while (1) { while (1) {
/* add user code begin 3 */ /* add user code begin 3 */