STM32 series single-chip microcomputer, this one-chip computer is powerful, and very easy to learn, the official example code is a lot, a little modification can develop one's own thing.
Embedded software is used with the latest version of the STM32CubeMX personal computer development tool. Designers can configure the microcontroller in the graphical interface wizard. With one click, initial C code can be generated and used directly in a variety of popular third-party developments. tool.
The STM32Nucleo development board allows developers to connect the entire I/O interface of the microcontroller and integrates the ST-Link debugger/programmer without the need to install a separate debugger. Finally, the STM32Nucleo development board has mbedTM functionality, which means that the development board can be directly linked to a personal computer and the development board can be executed directly in the mbed.org online development environment.
If you learn 51 before getting started. The STM32F103 series is the most convenient with keil4 for arm. If it is STM32F4 series, Keil5 for arm should be used.
one. Configuration interruptionVoid NVIC_ConfiguraTIon(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Set the Vector Table base locaTIon at 0x08004000
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000); // 1. Allocation interrupt vector table
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //Set interrupt priority
/* Enable the EXTI1 Interrupt
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQChannel; // Interrupt Channel
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; // Specifying preemption priority 1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // The second priority is 0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //Channel interrupt enable
NVIC_Init(&NVIC_InitStructure); //initialize interrupt
}
note:
If the external interrupt pin is PA1, PB1, PC1, PD1 then use EXTI1 for interrupts.
If we configure the external pins PA4, or PB4, or PC4, PD4, etc., then the external interrupt must also be EXTI4;
two. Configure GPIO pinsVoid GPIO_Configuration(void)
{
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //Select IO pin
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //Configure the interrupt pin and configure it as floating input
GPIO_Init(GPIOA, &GPIO_InitStructure); // Initialize pins
}
Note: If the pin is port 1 pin, the configured interrupt must be EXTI1.
three. Configure EXIT line to connect interrupt line and IO pinVoid EXIT1_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
//Connect EXTI Line1 to PB.01
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource1); //Connect EXTI line 1 to the first pin of port GPIOD
// Configure Key Button EXTI Line to generate an interrupt on both rising and falling edge
EXTI_InitStructure.EXTI_Line = EXTI_Line1; //Note: If pin 1 is configured, it must be EXTI_Line1
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; // Both falling and rising edges trigger
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); //initialize interrupt
}
To this interrupt configuration is complete, you can write interrupt handler.
Void EXTI1_IRQHandler(void)
{
If(EXTI_GetITStatus(EXTI_Line1) != RESET)
{
// Clear the EXTI line 9 pending bit
EXTI_ClearITPendingBit(EXTI_Line1);
_485_Baud_Check() ; // Call the handler function
}
}
Perkins ≥1000KW Diesel Generator
Perkins ≥1000KW Diesel Generator,Perkins Power Generator,Perkins Genset,Perkins Open Diesel Generator
Shanghai Kosta Electric Co., Ltd. , https://www.ksdgenerator.com