diff --git a/ElinsF103/Core/Src/main.c b/ElinsF103/Core/Src/main.c index 9bfb0c9c2daa5eb8d58a7475503aa3c5067b706b..b4fec83e12e8886420e603580e124bc78d91eb02 100644 --- a/ElinsF103/Core/Src/main.c +++ b/ElinsF103/Core/Src/main.c @@ -1,544 +1,577 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - * Copyright (c) 2024 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - v1.00 - 1.必须要CANHL必须要并联电阻,否则U2回传数据只有一个字节 - v1.03 - 1.解决上电丢第1字节问题 - ****************************************************************************** - */ -#define SOFTWARE 103 - -/* USER CODE END Header */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ -UartModbusDef UartModbusStruct={ - -// unsigned char UartModbusStruct.rxd_overT,UartModbusStruct.ModbusTranBuff[200], UartModbusStruct.ModbusTranPtr=0, UartModbusStruct.ModbusTranNum=0; -// u8 UartModbusStruct.ModbusRecBuff[200],UartModbusStruct.ModbusRecPtr=0; -// unsigned short UartModbusStruct.len_data,UartModbusStruct.add_data,UartModbusStruct.ModbusRecCRC;//,crc ; - 0,{0},0,0 - ,{0},0 - ,0,0,0 -// ///////////////////////////modbus通讯相关//////////////////////////////////////////////////////////////////////////////////////////// -// unsigned char UartModbusStruct.rxd_overT2,UartModbusStruct.ModbusTranBuff2[65],UartModbusStruct.ModbusTranPtr2=0,UartModbusStruct.ModbusTranNum2=0; -// u8 UartModbusStruct.ModbusRecBuff2[65],UartModbusStruct.ModbusRecPtr2=0; -// unsigned short UartModbusStruct.len_data2,UartModbusStruct.add_data2,UartModbusStruct.ModbusRecCRC2;//,crc2; - ,0,{0},0,0 - ,{0},0 - ,0,0,0 - -// unsigned char UartModbusStruct.rxd_overT3,UartModbusStruct.ModbusTranBuff3[70],UartModbusStruct.ModbusTranPtr3=0,UartModbusStruct.ModbusTranNum3=0; -// u8 UartModbusStruct.ModbusRecBuff3[70],UartModbusStruct.ModbusRecPtr3=0; -// unsigned short UartModbusStruct.len_data3,UartModbusStruct.add_data3,UartModbusStruct.ModbusRecCRC3;//,crc3; - ,0,{0},0,0 - ,{0},0 - ,0,0,0 - - -// unsigned char UartModbusStruct.rxd_overT4,UartModbusStruct.ModbusTranBuff4[50],UartModbusStruct.ModbusTranPtr4=0,UartModbusStruct.ModbusTranNum4=0; -// u8 UartModbusStruct.ModbusRecBuff4[50],UartModbusStruct.ModbusRecPtr4=0; -// unsigned short UartModbusStruct.len_data4,UartModbusStruct.add_data4,UartModbusStruct.ModbusRecCRC4;//,crc4; - ,0,{0},0,0 - ,{0},0 - ,0,0,0 - -// unsigned char UartModbusStruct.rxd_overT5,UartModbusStruct.ModbusTranBuff5[50],UartModbusStruct.ModbusTranPtr5=0,UartModbusStruct.ModbusTranNum5=0; -// u8 UartModbusStruct.ModbusRecBuff5[50],UartModbusStruct.ModbusRecPtr5=0; -// unsigned short UartModbusStruct.len_data5,UartModbusStruct.add_data5,UartModbusStruct.ModbusRecCRC5;//,crc5; - ,0,{0},0,0 - ,{0},0 - ,0,0,0 - -// unsigned char UartModbusStruct.rxd_overT6,UartModbusStruct.ModbusTranBuff6[50],UartModbusStruct.ModbusTranPtr6=0,UartModbusStruct.ModbusTranNum6=0; -// u8 UartModbusStruct.ModbusRecBuff6[50],UartModbusStruct.ModbusRecPtr6=0; -// unsigned short UartModbusStruct.len_data6,UartModbusStruct.add_data6,UartModbusStruct.ModbusRecCRC6;//,crc6; - ,0,{0},0,0 - ,{0},0 - ,0,0,0 -//unsigned char UartModbusStruct.UsartNum=1; - ,1 -//unsigned short usart3bautFun=9601,usart4baut=9601,usart5bautFun=9601; - ,0,0,0 -//unsigned short DebugBusying=500,UsbBusyT=0,RS232BusyT=0,UartModbusStruct.OSZuPtr=0,UartModbusStruct.OSPage=0; - ,500,0,0,0,0 -// unsigned short uart2ConfigChange=0,uart2ConfigChange=0; - ,0,0 - -}; - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ -unsigned short ModbusCommand=0; -GPIO_InitTypeDef GPIO_InitStruct = {0}; - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -TIM_HandleTypeDef htim3; - -UART_HandleTypeDef huart1; -UART_HandleTypeDef huart2; - -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_GPIO_Init(void); -static void MX_TIM3_Init(void); -static void MX_USART1_UART_Init(void); -static void MX_USART2_UART_Init(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) -{ - /* Prevent unused argument(s) compilation warning */ - //UNUSED(htim); - if(htim==&htim3){ - if(UartModbusStruct.rxd_overT2) - { - UartModbusStruct.rxd_overT2--; - if(UartModbusStruct.rxd_overT2==0) { - UartModbusStruct.ModbusTranBuff[0]=0xA1; - for(unsigned short ii=0;ii1){ - UartModbusStruct.ModbusTranBuff[0]=0xA1; - UartModbusStruct.ModbusTranBuff[1]=SOFTWARE; - UartModbusStruct.ModbusTranPtr=0; - HAL_UART_Transmit(&huart1,UartModbusStruct.ModbusTranBuff,UartModbusStruct.ModbusRecPtr,9999); - } - }else{ - UartModbusStruct.ModbusTranPtr2=0;UartModbusStruct.ModbusRecPtr2=0; - // HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2+UartModbusStruct.ModbusRecPtr2,8); - - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET); - SysTickDelay_us(20); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET); //指示灯闪烁 - SysTickDelay_us(2-1); //后面有延时,此处减去1uS - - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //GPIO_InitStruct.Alternate =GPIO_MODE_AF_PP GPIO_AF7_USART2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - // HAL_UART_Transmit(&huart2,UartModbusStruct.ModbusTranBuff2,1,9999); - if(UartModbusStruct.ModbusRecPtr>0){ - UartModbusStruct.ModbusTranBuff2[0]=0x55; - for(unsigned short ii=1;iiDR; //接收每一个数据,防止数组溢出。 -// } - if(0==UartModbusStruct.ModbusRecPtr2) - UartModbusStruct.ModbusRecBuff2[UartModbusStruct.ModbusRecPtr2]=USART2->DR; - UartModbusStruct.ModbusRecPtr2++; - HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2+UartModbusStruct.ModbusRecPtr2,1); - }else if(huart==&huart1){ //USART1->SR&0x10){ - UartModbusStruct.rxd_overT=10; //超过10mS超时! - // if(UartModbusStruct.ModbusRecPtrDR; //接收每一个数据,防止数组溢出。 - // } - if(0==UartModbusStruct.ModbusRecPtr) - UartModbusStruct.ModbusRecBuff[UartModbusStruct.ModbusRecPtr]=USART1->DR; - UartModbusStruct.ModbusRecPtr++; - if(UartModbusStruct.ModbusRecPtr<5) - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); - else - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); //指示灯闪烁 - - if(UartModbusStruct.ModbusRecPtr==1) { - if(UartModbusStruct.ModbusRecBuff[0]&0xA0) { //透传 - if( (UartModbusStruct.ModbusRecBuff[0]&0xA0)==0xA0) { //正常透传响应数据,仅透传 - ModbusCommand=0xA0; - } else if( (UartModbusStruct.ModbusRecBuff[0]&0x80) ) { //仅从机MCU,级联透传发送数据命令 - if( (UartModbusStruct.ModbusRecBuff[0]&0x0F)>1 ) { //地址大于1:继续透传! - ModbusCommand=0x80; - } else { - ModbusCommand=1; //0和1都默认为本机数据; 停止透传! - } - } - } else if( (UartModbusStruct.ModbusRecBuff[0]&0x0F)==0x01 ) { //第一个字节为通讯地址1,主MCU通用调试地址; //从MCU的D7bit地址为1,最高D7为透传功能 - ModbusCommand=1; - } - } - if(ModbusCommand&0x80) { //从机级联转发数据<-- 透传发送地址标志 - if(ModbusCommand!=0xA0){ //从机透传级联地址部分,减一; - UartModbusStruct.ModbusRecBuff[0]--; - ModbusCommand=0xA0; - } - while( (USART1->SR & (1<<7))==0 ); //发送为空 - USART1->DR =UartModbusStruct.ModbusRecBuff[UartModbusStruct.ModbusRecPtr-1]; - - } - //USART1->SR&=~0x10;//USART_ClearITPendingBit(USART1,USART_IT_RXNE); - - HAL_UART_Receive_IT(&huart1,UartModbusStruct.ModbusRecBuff+UartModbusStruct.ModbusRecPtr,1); - } -} -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_TIM3_Init(); - MX_USART1_UART_Init(); - //MX_USART2_UART_Init(); - /* USER CODE BEGIN 2 */ - HAL_TIM_Base_Start_IT(&htim3); - HAL_UART_Receive_IT(&huart1,UartModbusStruct.ModbusRecBuff,1); - HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2,1); - //__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE); - //__HAL_UART_ENABLE_IT(&huart1, UART_IT_TC); - //__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE); - - /* USER CODE END 2 */ - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { -// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); //指示灯闪烁 -// SysTickDelay_us(200000); //后面有延时,此处减去1uS -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); -// SysTickDelay_us(200000); - /* USER CODE END WHILE */ - - /* USER CODE BEGIN 3 */ - } - /* USER CODE END 3 */ -} - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - - /** Initializes the RCC Oscillators according to the specified parameters - * in the RCC_OscInitTypeDef structure. - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; - RCC_OscInitStruct.HSIState = RCC_HSI_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - Error_Handler(); - } - - /** Initializes the CPU, AHB and APB buses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) - { - Error_Handler(); - } -} - -/** - * @brief TIM3 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM3_Init(void) -{ - - /* USER CODE BEGIN TIM3_Init 0 */ - - /* USER CODE END TIM3_Init 0 */ - - TIM_ClockConfigTypeDef sClockSourceConfig = {0}; - TIM_MasterConfigTypeDef sMasterConfig = {0}; - - /* USER CODE BEGIN TIM3_Init 1 */ - - /* USER CODE END TIM3_Init 1 */ - htim3.Instance = TIM3; - htim3.Init.Prescaler = 0; - htim3.Init.CounterMode = TIM_COUNTERMODE_UP; - htim3.Init.Period = 36000; - htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV2; - htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; - if (HAL_TIM_Base_Init(&htim3) != HAL_OK) - { - Error_Handler(); - } - sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; - if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) - { - Error_Handler(); - } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN TIM3_Init 2 */ - - /* USER CODE END TIM3_Init 2 */ - -} - -/** - * @brief USART1 Initialization Function - * @param None - * @retval None - */ -static void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - huart1.Instance = USART1; - huart1.Init.BaudRate = 38400; - huart1.Init.WordLength = UART_WORDLENGTH_8B; - huart1.Init.StopBits = UART_STOPBITS_1; - huart1.Init.Parity = UART_PARITY_NONE; - huart1.Init.Mode = UART_MODE_TX_RX; - huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart1.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ - -} - -/** - * @brief USART2 Initialization Function - * @param None - * @retval None - */ -static void MX_USART2_UART_Init(void) -{ - - /* USER CODE BEGIN USART2_Init 0 */ - - /* USER CODE END USART2_Init 0 */ - - /* USER CODE BEGIN USART2_Init 1 */ - - /* USER CODE END USART2_Init 1 */ - huart2.Instance = USART2; - huart2.Init.BaudRate = 1000000; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX_RX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART2_Init 2 */ - - /* USER CODE END USART2_Init 2 */ - -} - -/** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ -static void MX_GPIO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; -/* USER CODE BEGIN MX_GPIO_Init_1 */ -/* USER CODE END MX_GPIO_Init_1 */ - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); - - /*Configure GPIO pin : PC13 */ - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - -/* USER CODE BEGIN MX_GPIO_Init_2 */ - - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); - - /*Configure GPIO pin : PB3 */ - GPIO_InitStruct.Pin = GPIO_PIN_3; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET); - -/* USER CODE END MX_GPIO_Init_2 */ -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - __disable_irq(); - while (1) - { - } - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + v1.00 + 1.必须要CANHL必须要并联电阻,否则U2回传数据只有一个字节 + v1.03 + 1.解决上电丢第1字节问题 + ****************************************************************************** + */ +#define SOFTWARE 103 + +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ +UartModbusDef UartModbusStruct={ + +// unsigned char UartModbusStruct.rxd_overT,UartModbusStruct.ModbusTranBuff[200], UartModbusStruct.ModbusTranPtr=0, UartModbusStruct.ModbusTranNum=0; +// u8 UartModbusStruct.ModbusRecBuff[200],UartModbusStruct.ModbusRecPtr=0; +// unsigned short UartModbusStruct.len_data,UartModbusStruct.add_data,UartModbusStruct.ModbusRecCRC;//,crc ; + 0,{0},0,0 + ,{0},0 + ,0,0,0 +// ///////////////////////////modbus通讯相关//////////////////////////////////////////////////////////////////////////////////////////// +// unsigned char UartModbusStruct.rxd_overT2,UartModbusStruct.ModbusTranBuff2[65],UartModbusStruct.ModbusTranPtr2=0,UartModbusStruct.ModbusTranNum2=0; +// u8 UartModbusStruct.ModbusRecBuff2[65],UartModbusStruct.ModbusRecPtr2=0; +// unsigned short UartModbusStruct.len_data2,UartModbusStruct.add_data2,UartModbusStruct.ModbusRecCRC2;//,crc2; + ,0,{0},0,0 + ,{0},0 + ,0,0,0 + +// unsigned char UartModbusStruct.rxd_overT3,UartModbusStruct.ModbusTranBuff3[70],UartModbusStruct.ModbusTranPtr3=0,UartModbusStruct.ModbusTranNum3=0; +// u8 UartModbusStruct.ModbusRecBuff3[70],UartModbusStruct.ModbusRecPtr3=0; +// unsigned short UartModbusStruct.len_data3,UartModbusStruct.add_data3,UartModbusStruct.ModbusRecCRC3;//,crc3; + ,0,{0},0,0 + ,{0},0 + ,0,0,0 + + +// unsigned char UartModbusStruct.rxd_overT4,UartModbusStruct.ModbusTranBuff4[50],UartModbusStruct.ModbusTranPtr4=0,UartModbusStruct.ModbusTranNum4=0; +// u8 UartModbusStruct.ModbusRecBuff4[50],UartModbusStruct.ModbusRecPtr4=0; +// unsigned short UartModbusStruct.len_data4,UartModbusStruct.add_data4,UartModbusStruct.ModbusRecCRC4;//,crc4; + ,0,{0},0,0 + ,{0},0 + ,0,0,0 + +// unsigned char UartModbusStruct.rxd_overT5,UartModbusStruct.ModbusTranBuff5[50],UartModbusStruct.ModbusTranPtr5=0,UartModbusStruct.ModbusTranNum5=0; +// u8 UartModbusStruct.ModbusRecBuff5[50],UartModbusStruct.ModbusRecPtr5=0; +// unsigned short UartModbusStruct.len_data5,UartModbusStruct.add_data5,UartModbusStruct.ModbusRecCRC5;//,crc5; + ,0,{0},0,0 + ,{0},0 + ,0,0,0 + +// unsigned char UartModbusStruct.rxd_overT6,UartModbusStruct.ModbusTranBuff6[50],UartModbusStruct.ModbusTranPtr6=0,UartModbusStruct.ModbusTranNum6=0; +// u8 UartModbusStruct.ModbusRecBuff6[50],UartModbusStruct.ModbusRecPtr6=0; +// unsigned short UartModbusStruct.len_data6,UartModbusStruct.add_data6,UartModbusStruct.ModbusRecCRC6;//,crc6; + ,0,{0},0,0 + ,{0},0 + ,0,0,0 +//unsigned char UartModbusStruct.UsartNum=1; + ,1 +//unsigned short usart3bautFun=9601,usart4baut=9601,usart5bautFun=9601; + ,0,0,0 +//unsigned short DebugBusying=500,UsbBusyT=0,RS232BusyT=0,UartModbusStruct.OSZuPtr=0,UartModbusStruct.OSPage=0; + ,500,0,0,0,0 +// unsigned short uart2ConfigChange=0,uart2ConfigChange=0; + ,0,0 + +}; + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +unsigned short ModbusCommand=0; +GPIO_InitTypeDef GPIO_InitStruct = {0}; + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +TIM_HandleTypeDef htim3; + +UART_HandleTypeDef huart1; +UART_HandleTypeDef huart2; + +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_TIM3_Init(void); +static void MX_USART1_UART_Init(void); +static void MX_USART2_UART_Init(void); +uint8_t USART_ReceiveData(void); +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ +#include "stm32f1xx_hal.h" + +void receiveData(uint8_t *data) { + + + *data =HAL_UART_Receive_IT(&huart1,UartModbusStruct.ModbusRecBuff,1); + + // 在这里实现接收数据的函数,将接收到的数据存储在data指针指向的内存中 +} + + + + + + + +void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) +{ + /* Prevent unused argument(s) compilation warning */ + //UNUSED(htim); + if(htim==&htim3){ + if(UartModbusStruct.rxd_overT2) + { + UartModbusStruct.rxd_overT2--; + if(UartModbusStruct.rxd_overT2==0) { + UartModbusStruct.ModbusTranBuff[0]=0xA1; + for(unsigned short ii=0;ii1){ + UartModbusStruct.ModbusTranBuff[0]=0xA1; + UartModbusStruct.ModbusTranBuff[1]=SOFTWARE; + UartModbusStruct.ModbusTranPtr=0; + HAL_UART_Transmit(&huart1,UartModbusStruct.ModbusTranBuff,UartModbusStruct.ModbusRecPtr,9999); + } + }else{ + UartModbusStruct.ModbusTranPtr2=0;UartModbusStruct.ModbusRecPtr2=0; + // HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2+UartModbusStruct.ModbusRecPtr2,8); + + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET); + SysTickDelay_us(20); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET); //指示灯闪烁 + SysTickDelay_us(2-1); //后面有延时,此处减去1uS + + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //GPIO_InitStruct.Alternate =GPIO_MODE_AF_PP GPIO_AF7_USART2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + // HAL_UART_Transmit(&huart2,UartModbusStruct.ModbusTranBuff2,1,9999); + if(UartModbusStruct.ModbusRecPtr>0){ + UartModbusStruct.ModbusTranBuff2[0]=0x55; + for(unsigned short ii=1;iiDR; //接收每一个数据,防止数组溢出。 +// } + if(0==UartModbusStruct.ModbusRecPtr2) + UartModbusStruct.ModbusRecBuff2[UartModbusStruct.ModbusRecPtr2]=USART2->DR; + UartModbusStruct.ModbusRecPtr2++; + HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2+UartModbusStruct.ModbusRecPtr2,1); + }else if(huart==&huart1){ //USART1->SR&0x10){ + UartModbusStruct.rxd_overT=10; //超过10mS超时! + // if(UartModbusStruct.ModbusRecPtrDR; //接收每一个数据,防止数组溢出。 + // } + if(0==UartModbusStruct.ModbusRecPtr) + UartModbusStruct.ModbusRecBuff[UartModbusStruct.ModbusRecPtr]=USART1->DR; + UartModbusStruct.ModbusRecPtr++; + + if(UartModbusStruct.ModbusRecPtr==1) { + if(UartModbusStruct.ModbusRecBuff[0]&0xA0) { //透传 + if( (UartModbusStruct.ModbusRecBuff[0]&0xA0)==0xA0) { //正常透传响应数据,仅透传 + ModbusCommand=0xA0; + } else if( (UartModbusStruct.ModbusRecBuff[0]&0x80) ) { //仅从机MCU,级联透传发送数据命令 + if( (UartModbusStruct.ModbusRecBuff[0]&0x0F)>1 ) { //地址大于1:继续透传! + ModbusCommand=0x80; + } else { + ModbusCommand=1; //0和1都默认为本机数据; 停止透传! + } + } + } else if( (UartModbusStruct.ModbusRecBuff[0]&0x0F)==0x01 ) { //第一个字节为通讯地址1,主MCU通用调试地址; //从MCU的D7bit地址为1,最高D7为透传功能 + ModbusCommand=1; + } + } + if(ModbusCommand&0x80) { //从机级联转发数据<-- 透传发送地址标志 + if(ModbusCommand!=0xA0){ //从机透传级联地址部分,减一; + UartModbusStruct.ModbusRecBuff[0]--; + ModbusCommand=0xA0; + } + while( (USART1->SR & (1<<7))==0 ); //发送为空 + USART1->DR =UartModbusStruct.ModbusRecBuff[UartModbusStruct.ModbusRecPtr-1]; + + } + //USART1->SR&=~0x10;//USART_ClearITPendingBit(USART1,USART_IT_RXNE); + + HAL_UART_Receive_IT(&huart1,UartModbusStruct.ModbusRecBuff+UartModbusStruct.ModbusRecPtr,1); + } +} +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + HAL_Init(); + SystemClock_Config(); + + + + uint8_t receivedData; + + /* USER CODE BEGIN 1 */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_TIM3_Init(); + MX_USART1_UART_Init(); + //MX_USART2_UART_Init(); + /* USER CODE BEGIN 2 */ + HAL_TIM_Base_Start_IT(&htim3); + HAL_UART_Receive_IT(&huart1,UartModbusStruct.ModbusRecBuff,1); + HAL_UART_Receive_IT(&huart2,UartModbusStruct.ModbusRecBuff2,1); + //__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE); + //__HAL_UART_ENABLE_IT(&huart1, UART_IT_TC); + //__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE); + + /* USER CODE END 2 */ + + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + receiveData(&receivedData); // 调用接收数据的函数 + + if (receivedData == 1) { + HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); // 灯亮 + } else if (receivedData == 0) { + HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); // 灯灭 + } + //HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); //指示灯闪烁 +// SysTickDelay_us(200000); //后面有延时,此处减去1uS +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); +// SysTickDelay_us(200000); + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_ClockConfigTypeDef sClockSourceConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 0; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 36000; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV2; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; + if (HAL_TIM_Base_Init(&htim3) != HAL_OK) + { + Error_Handler(); + } + sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; + if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + +} + +/** + * @brief USART1 Initialization Function + * @param None + * @retval None + */ +static void MX_USART1_UART_Init(void) +{ + + /* USER CODE BEGIN USART1_Init 0 */ + + /* USER CODE END USART1_Init 0 */ + + /* USER CODE BEGIN USART1_Init 1 */ + + /* USER CODE END USART1_Init 1 */ + huart1.Instance = USART1; + huart1.Init.BaudRate = 38400; + huart1.Init.WordLength = UART_WORDLENGTH_8B; + huart1.Init.StopBits = UART_STOPBITS_1; + huart1.Init.Parity = UART_PARITY_NONE; + huart1.Init.Mode = UART_MODE_TX_RX; + huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart1.Init.OverSampling = UART_OVERSAMPLING_16; + if (HAL_UART_Init(&huart1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USART1_Init 2 */ + + /* USER CODE END USART1_Init 2 */ + +} + +/** + * @brief USART2 Initialization Function + * @param None + * @retval None + */ +static void MX_USART2_UART_Init(void) +{ + + /* USER CODE BEGIN USART2_Init 0 */ + + /* USER CODE END USART2_Init 0 */ + + /* USER CODE BEGIN USART2_Init 1 */ + + /* USER CODE END USART2_Init 1 */ + huart2.Instance = USART2; + huart2.Init.BaudRate = 1000000; + huart2.Init.WordLength = UART_WORDLENGTH_8B; + huart2.Init.StopBits = UART_STOPBITS_1; + huart2.Init.Parity = UART_PARITY_NONE; + huart2.Init.Mode = UART_MODE_TX_RX; + huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart2.Init.OverSampling = UART_OVERSAMPLING_16; + if (HAL_UART_Init(&huart2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USART2_Init 2 */ + + /* USER CODE END USART2_Init 2 */ + +} + + + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; +/* USER CODE BEGIN MX_GPIO_Init_1 */ +/* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); + + /*Configure GPIO pin : PC13 */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + +/* USER CODE BEGIN MX_GPIO_Init_2 */ + + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); + + /*Configure GPIO pin : PB3 */ + GPIO_InitStruct.Pin = GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET); + +/* USER CODE END MX_GPIO_Init_2 */ +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ + __disable_irq(); + while (1) + { + } + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ diff --git a/ElinsF103/MDK-ARM/ElinsF103.uvoptx b/ElinsF103/MDK-ARM/ElinsF103.uvoptx index 3a4034283afe02f51767bd2c10b0cdf30127d6e8..4033331fee03ec597e876d69cb4f2cc287a0aa56 100644 --- a/ElinsF103/MDK-ARM/ElinsF103.uvoptx +++ b/ElinsF103/MDK-ARM/ElinsF103.uvoptx @@ -79,8 +79,8 @@ 18 - 1 - 0 + 0 + 1 1 1 1 @@ -103,7 +103,7 @@ 1 0 0 - 6 + 11 @@ -150,27 +150,10 @@ 0 ST-LINKIII-KEIL_SWO - -U16004A002933353739303541 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL010000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + -UE1007200D0D2139393740544 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL010000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) - - - 0 - 0 - 147 - 1 -
134218162
- 0 - 0 - 0 - 0 - 0 - 1 - startup_stm32f103xb.s - - \\ElinsF103\startup_stm32f103xb.s\147 -
-
+ 0 @@ -191,7 +174,7 @@ 0 0 0 - 1 + 0 0 0 0 @@ -213,12 +196,6 @@ - - - System Viewer\DAC - 35905 - - 1 0 @@ -259,7 +236,7 @@ 2 2 1 - 1 + 0 0 0 ../Core/Src/main.c @@ -471,7 +448,7 @@ Drivers/CMSIS - 1 + 0 0 0 0 diff --git a/ElinsF103/MDK-ARM/ElinsF103.uvprojx b/ElinsF103/MDK-ARM/ElinsF103.uvprojx index fae1cbad48d68575e6c766a991cee33a8a26c349..1940c47722176e11c581f33137897ac1a15563ef 100644 --- a/ElinsF103/MDK-ARM/ElinsF103.uvprojx +++ b/ElinsF103/MDK-ARM/ElinsF103.uvprojx @@ -10,13 +10,13 @@ ElinsF103 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::ARMCC 0 STM32F103C8 STMicroelectronics - Keil.STM32F1xx_DFP.2.0.0 + Keil.STM32F1xx_DFP.1.0.5 http://www.keil.com/pack/ IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3") TZ diff --git a/ElinsF103/MDK-ARM/startup_stm32f103xb.lst b/ElinsF103/MDK-ARM/startup_stm32f103xb.lst new file mode 100644 index 0000000000000000000000000000000000000000..9f8c5fe421af792e54d45bbe26a7e22fe898f7b3 --- /dev/null +++ b/ElinsF103/MDK-ARM/startup_stm32f103xb.lst @@ -0,0 +1,1206 @@ + + + +ARM Macro Assembler Page 1 + + + 1 00000000 ;******************** (C) COPYRIGHT 2017 STMicroelectron + ics ******************** + 2 00000000 ;* File Name : startup_stm32f103xb.s + 3 00000000 ;* Author : MCD Application Team + 4 00000000 ;* Description : STM32F103xB Devices vector table + for MDK-ARM toolchain. + 5 00000000 ;* This module performs: + 6 00000000 ;* - Set the initial SP + 7 00000000 ;* - Set the initial PC == Reset_Ha + ndler + 8 00000000 ;* - Set the vector table entries w + ith the exceptions ISR address + 9 00000000 ;* - Configure the clock system + 10 00000000 ;* - Branches to __main in the C li + brary (which eventually + 11 00000000 ;* calls main()). + 12 00000000 ;* After Reset the Cortex-M3 proces + sor is in Thread mode, + 13 00000000 ;* priority is Privileged, and the + Stack is set to Main. + 14 00000000 ;******************************************************* + *********************** + 15 00000000 ;* @attention + 16 00000000 ;* + 17 00000000 ;* Copyright (c) 2017-2021 STMicroelectronics. + 18 00000000 ;* All rights reserved. + 19 00000000 ;* + 20 00000000 ;* This software is licensed under terms that can be fou + nd in the LICENSE file + 21 00000000 ;* in the root directory of this software component. + 22 00000000 ;* If no LICENSE file comes with this software, it is pr + ovided AS-IS. + 23 00000000 ;* + 24 00000000 ;******************************************************* + *********************** + 25 00000000 + 26 00000000 ; Amount of memory (in bytes) allocated for Stack + 27 00000000 ; Tailor this value to your application needs + 28 00000000 ; Stack Configuration + 29 00000000 ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + 30 00000000 ; + 31 00000000 + 32 00000000 00000400 + Stack_Size + EQU 0x400 + 33 00000000 + 34 00000000 AREA STACK, NOINIT, READWRITE, ALIGN +=3 + 35 00000000 Stack_Mem + SPACE Stack_Size + 36 00000400 __initial_sp + 37 00000400 + 38 00000400 + 39 00000400 ; Heap Configuration + 40 00000400 ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + 41 00000400 ; + 42 00000400 + 43 00000400 00000200 + Heap_Size + + + +ARM Macro Assembler Page 2 + + + EQU 0x200 + 44 00000400 + 45 00000400 AREA HEAP, NOINIT, READWRITE, ALIGN= +3 + 46 00000000 __heap_base + 47 00000000 Heap_Mem + SPACE Heap_Size + 48 00000200 __heap_limit + 49 00000200 + 50 00000200 PRESERVE8 + 51 00000200 THUMB + 52 00000200 + 53 00000200 + 54 00000200 ; Vector Table Mapped to Address 0 at Reset + 55 00000200 AREA RESET, DATA, READONLY + 56 00000000 EXPORT __Vectors + 57 00000000 EXPORT __Vectors_End + 58 00000000 EXPORT __Vectors_Size + 59 00000000 + 60 00000000 00000000 + __Vectors + DCD __initial_sp ; Top of Stack + 61 00000004 00000000 DCD Reset_Handler ; Reset Handler + 62 00000008 00000000 DCD NMI_Handler ; NMI Handler + 63 0000000C 00000000 DCD HardFault_Handler ; Hard Fault + Handler + 64 00000010 00000000 DCD MemManage_Handler + ; MPU Fault Handler + + 65 00000014 00000000 DCD BusFault_Handler + ; Bus Fault Handler + + 66 00000018 00000000 DCD UsageFault_Handler ; Usage Faul + t Handler + 67 0000001C 00000000 DCD 0 ; Reserved + 68 00000020 00000000 DCD 0 ; Reserved + 69 00000024 00000000 DCD 0 ; Reserved + 70 00000028 00000000 DCD 0 ; Reserved + 71 0000002C 00000000 DCD SVC_Handler ; SVCall Handler + 72 00000030 00000000 DCD DebugMon_Handler ; Debug Monito + r Handler + 73 00000034 00000000 DCD 0 ; Reserved + 74 00000038 00000000 DCD PendSV_Handler ; PendSV Handler + + 75 0000003C 00000000 DCD SysTick_Handler + ; SysTick Handler + 76 00000040 + 77 00000040 ; External Interrupts + 78 00000040 00000000 DCD WWDG_IRQHandler + ; Window Watchdog + 79 00000044 00000000 DCD PVD_IRQHandler ; PVD through EX + TI Line detect + 80 00000048 00000000 DCD TAMPER_IRQHandler ; Tamper + 81 0000004C 00000000 DCD RTC_IRQHandler ; RTC + 82 00000050 00000000 DCD FLASH_IRQHandler ; Flash + 83 00000054 00000000 DCD RCC_IRQHandler ; RCC + 84 00000058 00000000 DCD EXTI0_IRQHandler ; EXTI Line 0 + 85 0000005C 00000000 DCD EXTI1_IRQHandler ; EXTI Line 1 + 86 00000060 00000000 DCD EXTI2_IRQHandler ; EXTI Line 2 + + + +ARM Macro Assembler Page 3 + + + 87 00000064 00000000 DCD EXTI3_IRQHandler ; EXTI Line 3 + 88 00000068 00000000 DCD EXTI4_IRQHandler ; EXTI Line 4 + 89 0000006C 00000000 DCD DMA1_Channel1_IRQHandler + ; DMA1 Channel 1 + 90 00000070 00000000 DCD DMA1_Channel2_IRQHandler + ; DMA1 Channel 2 + 91 00000074 00000000 DCD DMA1_Channel3_IRQHandler + ; DMA1 Channel 3 + 92 00000078 00000000 DCD DMA1_Channel4_IRQHandler + ; DMA1 Channel 4 + 93 0000007C 00000000 DCD DMA1_Channel5_IRQHandler + ; DMA1 Channel 5 + 94 00000080 00000000 DCD DMA1_Channel6_IRQHandler + ; DMA1 Channel 6 + 95 00000084 00000000 DCD DMA1_Channel7_IRQHandler + ; DMA1 Channel 7 + 96 00000088 00000000 DCD ADC1_2_IRQHandler ; ADC1_2 + 97 0000008C 00000000 DCD USB_HP_CAN1_TX_IRQHandler ; USB + High Priority or C + AN1 TX + 98 00000090 00000000 DCD USB_LP_CAN1_RX0_IRQHandler ; US + B Low Priority or + CAN1 RX0 + 99 00000094 00000000 DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + 100 00000098 00000000 DCD CAN1_SCE_IRQHandler ; CAN1 SCE + 101 0000009C 00000000 DCD EXTI9_5_IRQHandler + ; EXTI Line 9..5 + 102 000000A0 00000000 DCD TIM1_BRK_IRQHandler + ; TIM1 Break + 103 000000A4 00000000 DCD TIM1_UP_IRQHandler + ; TIM1 Update + 104 000000A8 00000000 DCD TIM1_TRG_COM_IRQHandler ; TIM1 + Trigger and Commuta + tion + 105 000000AC 00000000 DCD TIM1_CC_IRQHandler ; TIM1 Captu + re Compare + 106 000000B0 00000000 DCD TIM2_IRQHandler ; TIM2 + 107 000000B4 00000000 DCD TIM3_IRQHandler ; TIM3 + 108 000000B8 00000000 DCD TIM4_IRQHandler ; TIM4 + 109 000000BC 00000000 DCD I2C1_EV_IRQHandler ; I2C1 Event + + 110 000000C0 00000000 DCD I2C1_ER_IRQHandler ; I2C1 Error + + 111 000000C4 00000000 DCD I2C2_EV_IRQHandler ; I2C2 Event + + 112 000000C8 00000000 DCD I2C2_ER_IRQHandler ; I2C2 Error + + 113 000000CC 00000000 DCD SPI1_IRQHandler ; SPI1 + 114 000000D0 00000000 DCD SPI2_IRQHandler ; SPI2 + 115 000000D4 00000000 DCD USART1_IRQHandler ; USART1 + 116 000000D8 00000000 DCD USART2_IRQHandler ; USART2 + 117 000000DC 00000000 DCD USART3_IRQHandler ; USART3 + 118 000000E0 00000000 DCD EXTI15_10_IRQHandler + ; EXTI Line 15..10 + 119 000000E4 00000000 DCD RTC_Alarm_IRQHandler ; RTC Alar + m through EXTI Line + + 120 000000E8 00000000 DCD USBWakeUp_IRQHandler ; USB Wake + up from suspend + + + +ARM Macro Assembler Page 4 + + + 121 000000EC __Vectors_End + 122 000000EC + 123 000000EC 000000EC + __Vectors_Size + EQU __Vectors_End - __Vectors + 124 000000EC + 125 000000EC AREA |.text|, CODE, READONLY + 126 00000000 + 127 00000000 ; Reset handler + 128 00000000 Reset_Handler + PROC + 129 00000000 EXPORT Reset_Handler [WEAK +] + 130 00000000 IMPORT __main + 131 00000000 IMPORT SystemInit + 132 00000000 4809 LDR R0, =SystemInit + 133 00000002 4780 BLX R0 + 134 00000004 4809 LDR R0, =__main + 135 00000006 4700 BX R0 + 136 00000008 ENDP + 137 00000008 + 138 00000008 ; Dummy Exception Handlers (infinite loops which can be + modified) + 139 00000008 + 140 00000008 NMI_Handler + PROC + 141 00000008 EXPORT NMI_Handler [WEA +K] + 142 00000008 E7FE B . + 143 0000000A ENDP + 145 0000000A HardFault_Handler + PROC + 146 0000000A EXPORT HardFault_Handler [WEA +K] + 147 0000000A E7FE B . + 148 0000000C ENDP + 150 0000000C MemManage_Handler + PROC + 151 0000000C EXPORT MemManage_Handler [WEA +K] + 152 0000000C E7FE B . + 153 0000000E ENDP + 155 0000000E BusFault_Handler + PROC + 156 0000000E EXPORT BusFault_Handler [WEA +K] + 157 0000000E E7FE B . + 158 00000010 ENDP + 160 00000010 UsageFault_Handler + PROC + 161 00000010 EXPORT UsageFault_Handler [WEA +K] + 162 00000010 E7FE B . + 163 00000012 ENDP + 164 00000012 SVC_Handler + PROC + 165 00000012 EXPORT SVC_Handler [WEA +K] + 166 00000012 E7FE B . + + + +ARM Macro Assembler Page 5 + + + 167 00000014 ENDP + 169 00000014 DebugMon_Handler + PROC + 170 00000014 EXPORT DebugMon_Handler [WEA +K] + 171 00000014 E7FE B . + 172 00000016 ENDP + 173 00000016 PendSV_Handler + PROC + 174 00000016 EXPORT PendSV_Handler [WEA +K] + 175 00000016 E7FE B . + 176 00000018 ENDP + 177 00000018 SysTick_Handler + PROC + 178 00000018 EXPORT SysTick_Handler [WEA +K] + 179 00000018 E7FE B . + 180 0000001A ENDP + 181 0000001A + 182 0000001A Default_Handler + PROC + 183 0000001A + 184 0000001A EXPORT WWDG_IRQHandler [WEA +K] + 185 0000001A EXPORT PVD_IRQHandler [WEA +K] + 186 0000001A EXPORT TAMPER_IRQHandler [WEA +K] + 187 0000001A EXPORT RTC_IRQHandler [WEA +K] + 188 0000001A EXPORT FLASH_IRQHandler [WEA +K] + 189 0000001A EXPORT RCC_IRQHandler [WEA +K] + 190 0000001A EXPORT EXTI0_IRQHandler [WEA +K] + 191 0000001A EXPORT EXTI1_IRQHandler [WEA +K] + 192 0000001A EXPORT EXTI2_IRQHandler [WEA +K] + 193 0000001A EXPORT EXTI3_IRQHandler [WEA +K] + 194 0000001A EXPORT EXTI4_IRQHandler [WEA +K] + 195 0000001A EXPORT DMA1_Channel1_IRQHandler [WEA +K] + 196 0000001A EXPORT DMA1_Channel2_IRQHandler [WEA +K] + 197 0000001A EXPORT DMA1_Channel3_IRQHandler [WEA +K] + 198 0000001A EXPORT DMA1_Channel4_IRQHandler [WEA +K] + 199 0000001A EXPORT DMA1_Channel5_IRQHandler [WEA +K] + 200 0000001A EXPORT DMA1_Channel6_IRQHandler [WEA +K] + 201 0000001A EXPORT DMA1_Channel7_IRQHandler [WEA +K] + + + +ARM Macro Assembler Page 6 + + + 202 0000001A EXPORT ADC1_2_IRQHandler [WEA +K] + 203 0000001A EXPORT USB_HP_CAN1_TX_IRQHandler [WEA +K] + 204 0000001A EXPORT USB_LP_CAN1_RX0_IRQHandler [WEA +K] + 205 0000001A EXPORT CAN1_RX1_IRQHandler [WEA +K] + 206 0000001A EXPORT CAN1_SCE_IRQHandler [WEA +K] + 207 0000001A EXPORT EXTI9_5_IRQHandler [WEA +K] + 208 0000001A EXPORT TIM1_BRK_IRQHandler [WEA +K] + 209 0000001A EXPORT TIM1_UP_IRQHandler [WEA +K] + 210 0000001A EXPORT TIM1_TRG_COM_IRQHandler [WEA +K] + 211 0000001A EXPORT TIM1_CC_IRQHandler [WEA +K] + 212 0000001A EXPORT TIM2_IRQHandler [WEA +K] + 213 0000001A EXPORT TIM3_IRQHandler [WEA +K] + 214 0000001A EXPORT TIM4_IRQHandler [WEA +K] + 215 0000001A EXPORT I2C1_EV_IRQHandler [WEA +K] + 216 0000001A EXPORT I2C1_ER_IRQHandler [WEA +K] + 217 0000001A EXPORT I2C2_EV_IRQHandler [WEA +K] + 218 0000001A EXPORT I2C2_ER_IRQHandler [WEA +K] + 219 0000001A EXPORT SPI1_IRQHandler [WEA +K] + 220 0000001A EXPORT SPI2_IRQHandler [WEA +K] + 221 0000001A EXPORT USART1_IRQHandler [WEA +K] + 222 0000001A EXPORT USART2_IRQHandler [WEA +K] + 223 0000001A EXPORT USART3_IRQHandler [WEA +K] + 224 0000001A EXPORT EXTI15_10_IRQHandler [WEA +K] + 225 0000001A EXPORT RTC_Alarm_IRQHandler [WE +AK] + 226 0000001A EXPORT USBWakeUp_IRQHandler [WEA +K] + 227 0000001A + 228 0000001A WWDG_IRQHandler + 229 0000001A PVD_IRQHandler + 230 0000001A TAMPER_IRQHandler + 231 0000001A RTC_IRQHandler + 232 0000001A FLASH_IRQHandler + 233 0000001A RCC_IRQHandler + 234 0000001A EXTI0_IRQHandler + 235 0000001A EXTI1_IRQHandler + + + +ARM Macro Assembler Page 7 + + + 236 0000001A EXTI2_IRQHandler + 237 0000001A EXTI3_IRQHandler + 238 0000001A EXTI4_IRQHandler + 239 0000001A DMA1_Channel1_IRQHandler + 240 0000001A DMA1_Channel2_IRQHandler + 241 0000001A DMA1_Channel3_IRQHandler + 242 0000001A DMA1_Channel4_IRQHandler + 243 0000001A DMA1_Channel5_IRQHandler + 244 0000001A DMA1_Channel6_IRQHandler + 245 0000001A DMA1_Channel7_IRQHandler + 246 0000001A ADC1_2_IRQHandler + 247 0000001A USB_HP_CAN1_TX_IRQHandler + 248 0000001A USB_LP_CAN1_RX0_IRQHandler + 249 0000001A CAN1_RX1_IRQHandler + 250 0000001A CAN1_SCE_IRQHandler + 251 0000001A EXTI9_5_IRQHandler + 252 0000001A TIM1_BRK_IRQHandler + 253 0000001A TIM1_UP_IRQHandler + 254 0000001A TIM1_TRG_COM_IRQHandler + 255 0000001A TIM1_CC_IRQHandler + 256 0000001A TIM2_IRQHandler + 257 0000001A TIM3_IRQHandler + 258 0000001A TIM4_IRQHandler + 259 0000001A I2C1_EV_IRQHandler + 260 0000001A I2C1_ER_IRQHandler + 261 0000001A I2C2_EV_IRQHandler + 262 0000001A I2C2_ER_IRQHandler + 263 0000001A SPI1_IRQHandler + 264 0000001A SPI2_IRQHandler + 265 0000001A USART1_IRQHandler + 266 0000001A USART2_IRQHandler + 267 0000001A USART3_IRQHandler + 268 0000001A EXTI15_10_IRQHandler + 269 0000001A RTC_Alarm_IRQHandler + 270 0000001A USBWakeUp_IRQHandler + 271 0000001A + 272 0000001A E7FE B . + 273 0000001C + 274 0000001C ENDP + 275 0000001C + 276 0000001C ALIGN + 277 0000001C + 278 0000001C ;******************************************************* + ************************ + 279 0000001C ; User Stack and Heap initialization + 280 0000001C ;******************************************************* + ************************ + 281 0000001C IF :DEF:__MICROLIB + 288 0000001C + 289 0000001C IMPORT __use_two_region_memory + 290 0000001C EXPORT __user_initial_stackheap + 291 0000001C + 292 0000001C __user_initial_stackheap + 293 0000001C + 294 0000001C 4804 LDR R0, = Heap_Mem + 295 0000001E 4905 LDR R1, =(Stack_Mem + Stack_Size) + 296 00000020 4A05 LDR R2, = (Heap_Mem + Heap_Size) + 297 00000022 4B06 LDR R3, = Stack_Mem + 298 00000024 4770 BX LR + + + +ARM Macro Assembler Page 8 + + + 299 00000026 + 300 00000026 00 00 ALIGN + 301 00000028 + 302 00000028 ENDIF + 303 00000028 + 304 00000028 END + 00000000 + 00000000 + 00000000 + 00000400 + 00000200 + 00000000 +Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw +ork --depend=elinsf103\startup_stm32f103xb.d -oelinsf103\startup_stm32f103xb.o +-I.\RTE\_ElinsF103 -ID:\Keil_v5\ARM\PACK\ARM\CMSIS\5.7.0\CMSIS\Core\Include -ID +:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\1.0.5\Device\Include --predefine="__UVISI +ON_VERSION SETA 533" --predefine="_RTE_ SETA 1" --predefine="STM32F10X_MD SETA +1" --predefine="_RTE_ SETA 1" --list=startup_stm32f103xb.lst startup_stm32f103x +b.s + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +STACK 00000000 + +Symbol: STACK + Definitions + At line 34 in file startup_stm32f103xb.s + Uses + None +Comment: STACK unused +Stack_Mem 00000000 + +Symbol: Stack_Mem + Definitions + At line 35 in file startup_stm32f103xb.s + Uses + At line 295 in file startup_stm32f103xb.s + At line 297 in file startup_stm32f103xb.s + +__initial_sp 00000400 + +Symbol: __initial_sp + Definitions + At line 36 in file startup_stm32f103xb.s + Uses + At line 60 in file startup_stm32f103xb.s +Comment: __initial_sp used once +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +HEAP 00000000 + +Symbol: HEAP + Definitions + At line 45 in file startup_stm32f103xb.s + Uses + None +Comment: HEAP unused +Heap_Mem 00000000 + +Symbol: Heap_Mem + Definitions + At line 47 in file startup_stm32f103xb.s + Uses + At line 294 in file startup_stm32f103xb.s + At line 296 in file startup_stm32f103xb.s + +__heap_base 00000000 + +Symbol: __heap_base + Definitions + At line 46 in file startup_stm32f103xb.s + Uses + None +Comment: __heap_base unused +__heap_limit 00000200 + +Symbol: __heap_limit + Definitions + At line 48 in file startup_stm32f103xb.s + Uses + None +Comment: __heap_limit unused +4 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +RESET 00000000 + +Symbol: RESET + Definitions + At line 55 in file startup_stm32f103xb.s + Uses + None +Comment: RESET unused +__Vectors 00000000 + +Symbol: __Vectors + Definitions + At line 60 in file startup_stm32f103xb.s + Uses + At line 56 in file startup_stm32f103xb.s + At line 123 in file startup_stm32f103xb.s + +__Vectors_End 000000EC + +Symbol: __Vectors_End + Definitions + At line 121 in file startup_stm32f103xb.s + Uses + At line 57 in file startup_stm32f103xb.s + At line 123 in file startup_stm32f103xb.s + +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +.text 00000000 + +Symbol: .text + Definitions + At line 125 in file startup_stm32f103xb.s + Uses + None +Comment: .text unused +ADC1_2_IRQHandler 0000001A + +Symbol: ADC1_2_IRQHandler + Definitions + At line 246 in file startup_stm32f103xb.s + Uses + At line 96 in file startup_stm32f103xb.s + At line 202 in file startup_stm32f103xb.s + +BusFault_Handler 0000000E + +Symbol: BusFault_Handler + Definitions + At line 155 in file startup_stm32f103xb.s + Uses + At line 65 in file startup_stm32f103xb.s + At line 156 in file startup_stm32f103xb.s + +CAN1_RX1_IRQHandler 0000001A + +Symbol: CAN1_RX1_IRQHandler + Definitions + At line 249 in file startup_stm32f103xb.s + Uses + At line 99 in file startup_stm32f103xb.s + At line 205 in file startup_stm32f103xb.s + +CAN1_SCE_IRQHandler 0000001A + +Symbol: CAN1_SCE_IRQHandler + Definitions + At line 250 in file startup_stm32f103xb.s + Uses + At line 100 in file startup_stm32f103xb.s + At line 206 in file startup_stm32f103xb.s + +DMA1_Channel1_IRQHandler 0000001A + +Symbol: DMA1_Channel1_IRQHandler + Definitions + At line 239 in file startup_stm32f103xb.s + Uses + At line 89 in file startup_stm32f103xb.s + At line 195 in file startup_stm32f103xb.s + +DMA1_Channel2_IRQHandler 0000001A + +Symbol: DMA1_Channel2_IRQHandler + Definitions + At line 240 in file startup_stm32f103xb.s + Uses + + + +ARM Macro Assembler Page 2 Alphabetic symbol ordering +Relocatable symbols + + At line 90 in file startup_stm32f103xb.s + At line 196 in file startup_stm32f103xb.s + +DMA1_Channel3_IRQHandler 0000001A + +Symbol: DMA1_Channel3_IRQHandler + Definitions + At line 241 in file startup_stm32f103xb.s + Uses + At line 91 in file startup_stm32f103xb.s + At line 197 in file startup_stm32f103xb.s + +DMA1_Channel4_IRQHandler 0000001A + +Symbol: DMA1_Channel4_IRQHandler + Definitions + At line 242 in file startup_stm32f103xb.s + Uses + At line 92 in file startup_stm32f103xb.s + At line 198 in file startup_stm32f103xb.s + +DMA1_Channel5_IRQHandler 0000001A + +Symbol: DMA1_Channel5_IRQHandler + Definitions + At line 243 in file startup_stm32f103xb.s + Uses + At line 93 in file startup_stm32f103xb.s + At line 199 in file startup_stm32f103xb.s + +DMA1_Channel6_IRQHandler 0000001A + +Symbol: DMA1_Channel6_IRQHandler + Definitions + At line 244 in file startup_stm32f103xb.s + Uses + At line 94 in file startup_stm32f103xb.s + At line 200 in file startup_stm32f103xb.s + +DMA1_Channel7_IRQHandler 0000001A + +Symbol: DMA1_Channel7_IRQHandler + Definitions + At line 245 in file startup_stm32f103xb.s + Uses + At line 95 in file startup_stm32f103xb.s + At line 201 in file startup_stm32f103xb.s + +DebugMon_Handler 00000014 + +Symbol: DebugMon_Handler + Definitions + At line 169 in file startup_stm32f103xb.s + Uses + At line 72 in file startup_stm32f103xb.s + At line 170 in file startup_stm32f103xb.s + +Default_Handler 0000001A + + + + +ARM Macro Assembler Page 3 Alphabetic symbol ordering +Relocatable symbols + +Symbol: Default_Handler + Definitions + At line 182 in file startup_stm32f103xb.s + Uses + None +Comment: Default_Handler unused +EXTI0_IRQHandler 0000001A + +Symbol: EXTI0_IRQHandler + Definitions + At line 234 in file startup_stm32f103xb.s + Uses + At line 84 in file startup_stm32f103xb.s + At line 190 in file startup_stm32f103xb.s + +EXTI15_10_IRQHandler 0000001A + +Symbol: EXTI15_10_IRQHandler + Definitions + At line 268 in file startup_stm32f103xb.s + Uses + At line 118 in file startup_stm32f103xb.s + At line 224 in file startup_stm32f103xb.s + +EXTI1_IRQHandler 0000001A + +Symbol: EXTI1_IRQHandler + Definitions + At line 235 in file startup_stm32f103xb.s + Uses + At line 85 in file startup_stm32f103xb.s + At line 191 in file startup_stm32f103xb.s + +EXTI2_IRQHandler 0000001A + +Symbol: EXTI2_IRQHandler + Definitions + At line 236 in file startup_stm32f103xb.s + Uses + At line 86 in file startup_stm32f103xb.s + At line 192 in file startup_stm32f103xb.s + +EXTI3_IRQHandler 0000001A + +Symbol: EXTI3_IRQHandler + Definitions + At line 237 in file startup_stm32f103xb.s + Uses + At line 87 in file startup_stm32f103xb.s + At line 193 in file startup_stm32f103xb.s + +EXTI4_IRQHandler 0000001A + +Symbol: EXTI4_IRQHandler + Definitions + At line 238 in file startup_stm32f103xb.s + Uses + At line 88 in file startup_stm32f103xb.s + At line 194 in file startup_stm32f103xb.s + + + +ARM Macro Assembler Page 4 Alphabetic symbol ordering +Relocatable symbols + + +EXTI9_5_IRQHandler 0000001A + +Symbol: EXTI9_5_IRQHandler + Definitions + At line 251 in file startup_stm32f103xb.s + Uses + At line 101 in file startup_stm32f103xb.s + At line 207 in file startup_stm32f103xb.s + +FLASH_IRQHandler 0000001A + +Symbol: FLASH_IRQHandler + Definitions + At line 232 in file startup_stm32f103xb.s + Uses + At line 82 in file startup_stm32f103xb.s + At line 188 in file startup_stm32f103xb.s + +HardFault_Handler 0000000A + +Symbol: HardFault_Handler + Definitions + At line 145 in file startup_stm32f103xb.s + Uses + At line 63 in file startup_stm32f103xb.s + At line 146 in file startup_stm32f103xb.s + +I2C1_ER_IRQHandler 0000001A + +Symbol: I2C1_ER_IRQHandler + Definitions + At line 260 in file startup_stm32f103xb.s + Uses + At line 110 in file startup_stm32f103xb.s + At line 216 in file startup_stm32f103xb.s + +I2C1_EV_IRQHandler 0000001A + +Symbol: I2C1_EV_IRQHandler + Definitions + At line 259 in file startup_stm32f103xb.s + Uses + At line 109 in file startup_stm32f103xb.s + At line 215 in file startup_stm32f103xb.s + +I2C2_ER_IRQHandler 0000001A + +Symbol: I2C2_ER_IRQHandler + Definitions + At line 262 in file startup_stm32f103xb.s + Uses + At line 112 in file startup_stm32f103xb.s + At line 218 in file startup_stm32f103xb.s + +I2C2_EV_IRQHandler 0000001A + +Symbol: I2C2_EV_IRQHandler + Definitions + + + +ARM Macro Assembler Page 5 Alphabetic symbol ordering +Relocatable symbols + + At line 261 in file startup_stm32f103xb.s + Uses + At line 111 in file startup_stm32f103xb.s + At line 217 in file startup_stm32f103xb.s + +MemManage_Handler 0000000C + +Symbol: MemManage_Handler + Definitions + At line 150 in file startup_stm32f103xb.s + Uses + At line 64 in file startup_stm32f103xb.s + At line 151 in file startup_stm32f103xb.s + +NMI_Handler 00000008 + +Symbol: NMI_Handler + Definitions + At line 140 in file startup_stm32f103xb.s + Uses + At line 62 in file startup_stm32f103xb.s + At line 141 in file startup_stm32f103xb.s + +PVD_IRQHandler 0000001A + +Symbol: PVD_IRQHandler + Definitions + At line 229 in file startup_stm32f103xb.s + Uses + At line 79 in file startup_stm32f103xb.s + At line 185 in file startup_stm32f103xb.s + +PendSV_Handler 00000016 + +Symbol: PendSV_Handler + Definitions + At line 173 in file startup_stm32f103xb.s + Uses + At line 74 in file startup_stm32f103xb.s + At line 174 in file startup_stm32f103xb.s + +RCC_IRQHandler 0000001A + +Symbol: RCC_IRQHandler + Definitions + At line 233 in file startup_stm32f103xb.s + Uses + At line 83 in file startup_stm32f103xb.s + At line 189 in file startup_stm32f103xb.s + +RTC_Alarm_IRQHandler 0000001A + +Symbol: RTC_Alarm_IRQHandler + Definitions + At line 269 in file startup_stm32f103xb.s + Uses + At line 119 in file startup_stm32f103xb.s + At line 225 in file startup_stm32f103xb.s + + + + +ARM Macro Assembler Page 6 Alphabetic symbol ordering +Relocatable symbols + +RTC_IRQHandler 0000001A + +Symbol: RTC_IRQHandler + Definitions + At line 231 in file startup_stm32f103xb.s + Uses + At line 81 in file startup_stm32f103xb.s + At line 187 in file startup_stm32f103xb.s + +Reset_Handler 00000000 + +Symbol: Reset_Handler + Definitions + At line 128 in file startup_stm32f103xb.s + Uses + At line 61 in file startup_stm32f103xb.s + At line 129 in file startup_stm32f103xb.s + +SPI1_IRQHandler 0000001A + +Symbol: SPI1_IRQHandler + Definitions + At line 263 in file startup_stm32f103xb.s + Uses + At line 113 in file startup_stm32f103xb.s + At line 219 in file startup_stm32f103xb.s + +SPI2_IRQHandler 0000001A + +Symbol: SPI2_IRQHandler + Definitions + At line 264 in file startup_stm32f103xb.s + Uses + At line 114 in file startup_stm32f103xb.s + At line 220 in file startup_stm32f103xb.s + +SVC_Handler 00000012 + +Symbol: SVC_Handler + Definitions + At line 164 in file startup_stm32f103xb.s + Uses + At line 71 in file startup_stm32f103xb.s + At line 165 in file startup_stm32f103xb.s + +SysTick_Handler 00000018 + +Symbol: SysTick_Handler + Definitions + At line 177 in file startup_stm32f103xb.s + Uses + At line 75 in file startup_stm32f103xb.s + At line 178 in file startup_stm32f103xb.s + +TAMPER_IRQHandler 0000001A + +Symbol: TAMPER_IRQHandler + Definitions + At line 230 in file startup_stm32f103xb.s + + + +ARM Macro Assembler Page 7 Alphabetic symbol ordering +Relocatable symbols + + Uses + At line 80 in file startup_stm32f103xb.s + At line 186 in file startup_stm32f103xb.s + +TIM1_BRK_IRQHandler 0000001A + +Symbol: TIM1_BRK_IRQHandler + Definitions + At line 252 in file startup_stm32f103xb.s + Uses + At line 102 in file startup_stm32f103xb.s + At line 208 in file startup_stm32f103xb.s + +TIM1_CC_IRQHandler 0000001A + +Symbol: TIM1_CC_IRQHandler + Definitions + At line 255 in file startup_stm32f103xb.s + Uses + At line 105 in file startup_stm32f103xb.s + At line 211 in file startup_stm32f103xb.s + +TIM1_TRG_COM_IRQHandler 0000001A + +Symbol: TIM1_TRG_COM_IRQHandler + Definitions + At line 254 in file startup_stm32f103xb.s + Uses + At line 104 in file startup_stm32f103xb.s + At line 210 in file startup_stm32f103xb.s + +TIM1_UP_IRQHandler 0000001A + +Symbol: TIM1_UP_IRQHandler + Definitions + At line 253 in file startup_stm32f103xb.s + Uses + At line 103 in file startup_stm32f103xb.s + At line 209 in file startup_stm32f103xb.s + +TIM2_IRQHandler 0000001A + +Symbol: TIM2_IRQHandler + Definitions + At line 256 in file startup_stm32f103xb.s + Uses + At line 106 in file startup_stm32f103xb.s + At line 212 in file startup_stm32f103xb.s + +TIM3_IRQHandler 0000001A + +Symbol: TIM3_IRQHandler + Definitions + At line 257 in file startup_stm32f103xb.s + Uses + At line 107 in file startup_stm32f103xb.s + At line 213 in file startup_stm32f103xb.s + +TIM4_IRQHandler 0000001A + + + +ARM Macro Assembler Page 8 Alphabetic symbol ordering +Relocatable symbols + + +Symbol: TIM4_IRQHandler + Definitions + At line 258 in file startup_stm32f103xb.s + Uses + At line 108 in file startup_stm32f103xb.s + At line 214 in file startup_stm32f103xb.s + +USART1_IRQHandler 0000001A + +Symbol: USART1_IRQHandler + Definitions + At line 265 in file startup_stm32f103xb.s + Uses + At line 115 in file startup_stm32f103xb.s + At line 221 in file startup_stm32f103xb.s + +USART2_IRQHandler 0000001A + +Symbol: USART2_IRQHandler + Definitions + At line 266 in file startup_stm32f103xb.s + Uses + At line 116 in file startup_stm32f103xb.s + At line 222 in file startup_stm32f103xb.s + +USART3_IRQHandler 0000001A + +Symbol: USART3_IRQHandler + Definitions + At line 267 in file startup_stm32f103xb.s + Uses + At line 117 in file startup_stm32f103xb.s + At line 223 in file startup_stm32f103xb.s + +USBWakeUp_IRQHandler 0000001A + +Symbol: USBWakeUp_IRQHandler + Definitions + At line 270 in file startup_stm32f103xb.s + Uses + At line 120 in file startup_stm32f103xb.s + At line 226 in file startup_stm32f103xb.s + +USB_HP_CAN1_TX_IRQHandler 0000001A + +Symbol: USB_HP_CAN1_TX_IRQHandler + Definitions + At line 247 in file startup_stm32f103xb.s + Uses + At line 97 in file startup_stm32f103xb.s + At line 203 in file startup_stm32f103xb.s + +USB_LP_CAN1_RX0_IRQHandler 0000001A + +Symbol: USB_LP_CAN1_RX0_IRQHandler + Definitions + At line 248 in file startup_stm32f103xb.s + Uses + + + +ARM Macro Assembler Page 9 Alphabetic symbol ordering +Relocatable symbols + + At line 98 in file startup_stm32f103xb.s + At line 204 in file startup_stm32f103xb.s + +UsageFault_Handler 00000010 + +Symbol: UsageFault_Handler + Definitions + At line 160 in file startup_stm32f103xb.s + Uses + At line 66 in file startup_stm32f103xb.s + At line 161 in file startup_stm32f103xb.s + +WWDG_IRQHandler 0000001A + +Symbol: WWDG_IRQHandler + Definitions + At line 228 in file startup_stm32f103xb.s + Uses + At line 78 in file startup_stm32f103xb.s + At line 184 in file startup_stm32f103xb.s + +__user_initial_stackheap 0000001C + +Symbol: __user_initial_stackheap + Definitions + At line 292 in file startup_stm32f103xb.s + Uses + At line 290 in file startup_stm32f103xb.s +Comment: __user_initial_stackheap used once +56 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Absolute symbols + +Heap_Size 00000200 + +Symbol: Heap_Size + Definitions + At line 43 in file startup_stm32f103xb.s + Uses + At line 47 in file startup_stm32f103xb.s + At line 296 in file startup_stm32f103xb.s + +Stack_Size 00000400 + +Symbol: Stack_Size + Definitions + At line 32 in file startup_stm32f103xb.s + Uses + At line 35 in file startup_stm32f103xb.s + At line 295 in file startup_stm32f103xb.s + +__Vectors_Size 000000EC + +Symbol: __Vectors_Size + Definitions + At line 123 in file startup_stm32f103xb.s + Uses + At line 58 in file startup_stm32f103xb.s +Comment: __Vectors_Size used once +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +External symbols + +SystemInit 00000000 + +Symbol: SystemInit + Definitions + At line 131 in file startup_stm32f103xb.s + Uses + At line 132 in file startup_stm32f103xb.s +Comment: SystemInit used once +__main 00000000 + +Symbol: __main + Definitions + At line 130 in file startup_stm32f103xb.s + Uses + At line 134 in file startup_stm32f103xb.s +Comment: __main used once +__use_two_region_memory 00000000 + +Symbol: __use_two_region_memory + Definitions + At line 289 in file startup_stm32f103xb.s + Uses + None +Comment: __use_two_region_memory unused +3 symbols +409 symbols in table diff --git a/ElinsF103/MDK-ARM/startup_stm32f103xb.s b/ElinsF103/MDK-ARM/startup_stm32f103xb.s index fd82d4f102c9daedbc3d44186d4196bb06b56b20..00aced1608dda61d430445bea9ed514cfa8c73f1 100644 --- a/ElinsF103/MDK-ARM/startup_stm32f103xb.s +++ b/ElinsF103/MDK-ARM/startup_stm32f103xb.s @@ -1,305 +1,305 @@ -;******************** (C) COPYRIGHT 2017 STMicroelectronics ******************** -;* File Name : startup_stm32f103xb.s -;* Author : MCD Application Team -;* Description : STM32F103xB Devices vector table for MDK-ARM toolchain. -;* This module performs: -;* - Set the initial SP -;* - Set the initial PC == Reset_Handler -;* - Set the vector table entries with the exceptions ISR address -;* - Configure the clock system -;* - Branches to __main in the C library (which eventually -;* calls main()). -;* After Reset the Cortex-M3 processor is in Thread mode, -;* priority is Privileged, and the Stack is set to Main. -;****************************************************************************** -;* @attention -;* -;* Copyright (c) 2017-2021 STMicroelectronics. -;* All rights reserved. -;* -;* This software is licensed under terms that can be found in the LICENSE file -;* in the root directory of this software component. -;* If no LICENSE file comes with this software, it is provided AS-IS. -;* -;****************************************************************************** - -; Amount of memory (in bytes) allocated for Stack -; Tailor this value to your application needs -; Stack Configuration -; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> -; - -Stack_Size EQU 0x400 - - AREA STACK, NOINIT, READWRITE, ALIGN=3 -Stack_Mem SPACE Stack_Size -__initial_sp - - -; Heap Configuration -; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> -; - -Heap_Size EQU 0x200 - - AREA HEAP, NOINIT, READWRITE, ALIGN=3 -__heap_base -Heap_Mem SPACE Heap_Size -__heap_limit - - PRESERVE8 - THUMB - - -; Vector Table Mapped to Address 0 at Reset - AREA RESET, DATA, READONLY - EXPORT __Vectors - EXPORT __Vectors_End - EXPORT __Vectors_Size - -__Vectors DCD __initial_sp ; Top of Stack - DCD Reset_Handler ; Reset Handler - DCD NMI_Handler ; NMI Handler - DCD HardFault_Handler ; Hard Fault Handler - DCD MemManage_Handler ; MPU Fault Handler - DCD BusFault_Handler ; Bus Fault Handler - DCD UsageFault_Handler ; Usage Fault Handler - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD 0 ; Reserved - DCD SVC_Handler ; SVCall Handler - DCD DebugMon_Handler ; Debug Monitor Handler - DCD 0 ; Reserved - DCD PendSV_Handler ; PendSV Handler - DCD SysTick_Handler ; SysTick Handler - - ; External Interrupts - DCD WWDG_IRQHandler ; Window Watchdog - DCD PVD_IRQHandler ; PVD through EXTI Line detect - DCD TAMPER_IRQHandler ; Tamper - DCD RTC_IRQHandler ; RTC - DCD FLASH_IRQHandler ; Flash - DCD RCC_IRQHandler ; RCC - DCD EXTI0_IRQHandler ; EXTI Line 0 - DCD EXTI1_IRQHandler ; EXTI Line 1 - DCD EXTI2_IRQHandler ; EXTI Line 2 - DCD EXTI3_IRQHandler ; EXTI Line 3 - DCD EXTI4_IRQHandler ; EXTI Line 4 - DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 - DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 - DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 - DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 - DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 - DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 - DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 - DCD ADC1_2_IRQHandler ; ADC1_2 - DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX - DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 - DCD CAN1_RX1_IRQHandler ; CAN1 RX1 - DCD CAN1_SCE_IRQHandler ; CAN1 SCE - DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 - DCD TIM1_BRK_IRQHandler ; TIM1 Break - DCD TIM1_UP_IRQHandler ; TIM1 Update - DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation - DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare - DCD TIM2_IRQHandler ; TIM2 - DCD TIM3_IRQHandler ; TIM3 - DCD TIM4_IRQHandler ; TIM4 - DCD I2C1_EV_IRQHandler ; I2C1 Event - DCD I2C1_ER_IRQHandler ; I2C1 Error - DCD I2C2_EV_IRQHandler ; I2C2 Event - DCD I2C2_ER_IRQHandler ; I2C2 Error - DCD SPI1_IRQHandler ; SPI1 - DCD SPI2_IRQHandler ; SPI2 - DCD USART1_IRQHandler ; USART1 - DCD USART2_IRQHandler ; USART2 - DCD USART3_IRQHandler ; USART3 - DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 - DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line - DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend -__Vectors_End - -__Vectors_Size EQU __Vectors_End - __Vectors - - AREA |.text|, CODE, READONLY - -; Reset handler -Reset_Handler PROC - EXPORT Reset_Handler [WEAK] - IMPORT __main - IMPORT SystemInit - LDR R0, =SystemInit - BLX R0 - LDR R0, =__main - BX R0 - ENDP - -; Dummy Exception Handlers (infinite loops which can be modified) - -NMI_Handler PROC - EXPORT NMI_Handler [WEAK] - B . - ENDP -HardFault_Handler\ - PROC - EXPORT HardFault_Handler [WEAK] - B . - ENDP -MemManage_Handler\ - PROC - EXPORT MemManage_Handler [WEAK] - B . - ENDP -BusFault_Handler\ - PROC - EXPORT BusFault_Handler [WEAK] - B . - ENDP -UsageFault_Handler\ - PROC - EXPORT UsageFault_Handler [WEAK] - B . - ENDP -SVC_Handler PROC - EXPORT SVC_Handler [WEAK] - B . - ENDP -DebugMon_Handler\ - PROC - EXPORT DebugMon_Handler [WEAK] - B . - ENDP -PendSV_Handler PROC - EXPORT PendSV_Handler [WEAK] - B . - ENDP -SysTick_Handler PROC - EXPORT SysTick_Handler [WEAK] - B . - ENDP - -Default_Handler PROC - - EXPORT WWDG_IRQHandler [WEAK] - EXPORT PVD_IRQHandler [WEAK] - EXPORT TAMPER_IRQHandler [WEAK] - EXPORT RTC_IRQHandler [WEAK] - EXPORT FLASH_IRQHandler [WEAK] - EXPORT RCC_IRQHandler [WEAK] - EXPORT EXTI0_IRQHandler [WEAK] - EXPORT EXTI1_IRQHandler [WEAK] - EXPORT EXTI2_IRQHandler [WEAK] - EXPORT EXTI3_IRQHandler [WEAK] - EXPORT EXTI4_IRQHandler [WEAK] - EXPORT DMA1_Channel1_IRQHandler [WEAK] - EXPORT DMA1_Channel2_IRQHandler [WEAK] - EXPORT DMA1_Channel3_IRQHandler [WEAK] - EXPORT DMA1_Channel4_IRQHandler [WEAK] - EXPORT DMA1_Channel5_IRQHandler [WEAK] - EXPORT DMA1_Channel6_IRQHandler [WEAK] - EXPORT DMA1_Channel7_IRQHandler [WEAK] - EXPORT ADC1_2_IRQHandler [WEAK] - EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] - EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] - EXPORT CAN1_RX1_IRQHandler [WEAK] - EXPORT CAN1_SCE_IRQHandler [WEAK] - EXPORT EXTI9_5_IRQHandler [WEAK] - EXPORT TIM1_BRK_IRQHandler [WEAK] - EXPORT TIM1_UP_IRQHandler [WEAK] - EXPORT TIM1_TRG_COM_IRQHandler [WEAK] - EXPORT TIM1_CC_IRQHandler [WEAK] - EXPORT TIM2_IRQHandler [WEAK] - EXPORT TIM3_IRQHandler [WEAK] - EXPORT TIM4_IRQHandler [WEAK] - EXPORT I2C1_EV_IRQHandler [WEAK] - EXPORT I2C1_ER_IRQHandler [WEAK] - EXPORT I2C2_EV_IRQHandler [WEAK] - EXPORT I2C2_ER_IRQHandler [WEAK] - EXPORT SPI1_IRQHandler [WEAK] - EXPORT SPI2_IRQHandler [WEAK] - EXPORT USART1_IRQHandler [WEAK] - EXPORT USART2_IRQHandler [WEAK] - EXPORT USART3_IRQHandler [WEAK] - EXPORT EXTI15_10_IRQHandler [WEAK] - EXPORT RTC_Alarm_IRQHandler [WEAK] - EXPORT USBWakeUp_IRQHandler [WEAK] - -WWDG_IRQHandler -PVD_IRQHandler -TAMPER_IRQHandler -RTC_IRQHandler -FLASH_IRQHandler -RCC_IRQHandler -EXTI0_IRQHandler -EXTI1_IRQHandler -EXTI2_IRQHandler -EXTI3_IRQHandler -EXTI4_IRQHandler -DMA1_Channel1_IRQHandler -DMA1_Channel2_IRQHandler -DMA1_Channel3_IRQHandler -DMA1_Channel4_IRQHandler -DMA1_Channel5_IRQHandler -DMA1_Channel6_IRQHandler -DMA1_Channel7_IRQHandler -ADC1_2_IRQHandler -USB_HP_CAN1_TX_IRQHandler -USB_LP_CAN1_RX0_IRQHandler -CAN1_RX1_IRQHandler -CAN1_SCE_IRQHandler -EXTI9_5_IRQHandler -TIM1_BRK_IRQHandler -TIM1_UP_IRQHandler -TIM1_TRG_COM_IRQHandler -TIM1_CC_IRQHandler -TIM2_IRQHandler -TIM3_IRQHandler -TIM4_IRQHandler -I2C1_EV_IRQHandler -I2C1_ER_IRQHandler -I2C2_EV_IRQHandler -I2C2_ER_IRQHandler -SPI1_IRQHandler -SPI2_IRQHandler -USART1_IRQHandler -USART2_IRQHandler -USART3_IRQHandler -EXTI15_10_IRQHandler -RTC_Alarm_IRQHandler -USBWakeUp_IRQHandler - - B . - - ENDP - - ALIGN - -;******************************************************************************* -; User Stack and Heap initialization -;******************************************************************************* - IF :DEF:__MICROLIB - - EXPORT __initial_sp - EXPORT __heap_base - EXPORT __heap_limit - - ELSE - - IMPORT __use_two_region_memory - EXPORT __user_initial_stackheap - -__user_initial_stackheap - - LDR R0, = Heap_Mem - LDR R1, =(Stack_Mem + Stack_Size) - LDR R2, = (Heap_Mem + Heap_Size) - LDR R3, = Stack_Mem - BX LR - - ALIGN - - ENDIF - - END - +;******************** (C) COPYRIGHT 2017 STMicroelectronics ******************** +;* File Name : startup_stm32f103xb.s +;* Author : MCD Application Team +;* Description : STM32F103xB Devices vector table for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the Cortex-M3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;****************************************************************************** +;* @attention +;* +;* Copyright (c) 2017-2021 STMicroelectronics. +;* All rights reserved. +;* +;* This software is licensed under terms that can be found in the LICENSE file +;* in the root directory of this software component. +;* If no LICENSE file comes with this software, it is provided AS-IS. +;* +;****************************************************************************** + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1_2 + DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX + DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_IRQHandler ; TIM1 Break + DCD TIM1_UP_IRQHandler ; TIM1 Update + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line + DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] + EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_IRQHandler [WEAK] + EXPORT TIM1_UP_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTC_Alarm_IRQHandler [WEAK] + EXPORT USBWakeUp_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +USB_HP_CAN1_TX_IRQHandler +USB_LP_CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_IRQHandler +TIM1_UP_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTC_Alarm_IRQHandler +USBWakeUp_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END +