GD32调用NVIC_SystemReset跳转不到IAP有什么解决的办法吗?

我的项目碰到一台机跳转不到IAP的问题,
利用的是__set_FAULTMASK(1); // close all IT
NVIC_SystemReset(); // reset
我开始怀疑是不是这台机器的mcu坏了,但试着读取出来的bin文件与我下载进去的bin文件是一样的,希望大家可以提供下建议,在这先谢谢各位大侠了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
stm32中可以定义2个一样名字的函数吗,比如另个NVIC_Configuration()

我现在看到的一个程序里面他一共定义了2个这个函数,一个是在main函数所在的源文件中,另一个里面的他前面加了static,加static的那个函数是不是只在那个源文件中才能被调用,而且是从定义它的地方开始,? 我可以2个都加static吗?这个函数设计到外设的优先级,定义2个函数,如果他们的优先级设置是一样的,主优先级和此优先级都是0,那么如果他们同时中断会不会有问题

CM4 NVIC优先级的问题

![图片说明](https://img-ask.csdn.net/upload/201701/12/1484205223_967871.jpg) ![图片说明](https://img-ask.csdn.net/upload/201701/12/1484205213_559156.jpg) CM4的资料就给这么点说明,也百度过好多贴子,不明白该怎么操作,才能设置不同的优先级,还有就是怎么分主优先级和子优先级。 我理解是往NVIC->IP里写一个值(值是范围是0~7),值越大,该优先级就越小,不知道对不对 我所参考的源代码是MQX4.1的代码,文件名为nvic.c ``` /*! * \brief Initialize a specific interrupt in the cortex core nvic * * \param[in] irq Interrupt number * \param[in] prior Interrupt priority * \param[in] enable enable the interrupt now? * * \return uint32_t MQX_OK or error code */ _mqx_uint _nvic_int_init ( // [IN] Interrupt number _mqx_uint irq, // [IN] Interrupt priority _mqx_uint prior, // [IN] enable the interrupt now? bool enable ) { VCORTEX_NVIC_STRUCT_PTR nvic = (VCORTEX_NVIC_STRUCT_PTR)&(((CORTEX_SCS_STRUCT_PTR)CORTEX_PRI_PERIPH_IN_BASE)->NVIC); _mqx_uint ext_irq_no = irq - 16; // check priority value, must be below maximal enabled/set value if (prior >= (1 << CORTEX_PRIOR_IMPL)) { return MQX_INVALID_PARAMETER; } if (irq >= PSP_INT_FIRST_INTERNAL && irq <= PSP_INT_LAST_INTERNAL) { nvic->PRIORITY[ext_irq_no >> 2] = (nvic->PRIORITY[ext_irq_no >> 2] & ~(0xff << ((ext_irq_no & 3) * 8))) | (((prior << CORTEX_PRIOR_SHIFT) & CORTEX_PRIOR_MASK) << ((ext_irq_no & 3) * 8)); if (enable) _nvic_int_enable(irq); else _nvic_int_disable(irq); } else return MQX_INVALID_PARAMETER; return MQX_OK; } /*! * \brief Enable interrupt on cortex core NVIC * * \param[in] irq Interrupt number * * \return uint32_t MQX_OK or error code */ _mqx_uint _nvic_int_enable ( // [IN] Interrupt number _mqx_uint irq ) { VCORTEX_NVIC_STRUCT_PTR nvic = (VCORTEX_NVIC_STRUCT_PTR)&(((CORTEX_SCS_STRUCT_PTR)CORTEX_PRI_PERIPH_IN_BASE)->NVIC); uint32_t ext_irq_no = irq - 16; if (ext_irq_no >= PSP_INT_FIRST_INTERNAL && ext_irq_no <= PSP_INT_LAST_INTERNAL) { nvic->ENABLE[ext_irq_no >> 5] = 1 << (ext_irq_no & 0x1f); } else return MQX_INVALID_PARAMETER; return MQX_OK; } /*! * \brief Disable interrupt on cortex core NVIC * * \param[in] irq Interrupt number * * \return uint32_t MQX_OK or error code */ _mqx_uint _nvic_int_disable ( // [IN] Interrupt number _mqx_uint irq ) { VCORTEX_NVIC_STRUCT_PTR nvic = (VCORTEX_NVIC_STRUCT_PTR)&(((CORTEX_SCS_STRUCT_PTR)CORTEX_PRI_PERIPH_IN_BASE)->NVIC); uint32_t ext_irq_no = irq - 16; if (ext_irq_no >= PSP_INT_FIRST_INTERNAL && ext_irq_no <= PSP_INT_LAST_INTERNAL) { nvic->DISABLE[ext_irq_no >> 5] = 1 << (ext_irq_no & 0x1f); } else return MQX_INVALID_PARAMETER; return MQX_OK; } ``` ``` ```

为什么stm32f4的中断跳到startup_stm32f40_41xxx.s库中后就跳不出来了

为什么我的中断函数跳到startup_stm32f40_41xxx.s库中后就跳不出来了。![![图片说明](https://img-ask.csdn.net/upload/201807/17/1531813979_881771.png)图片说明](https://img-ask.csdn.net/upload/201807/17/1531813971_83556.png) debug到中断初始化之后就动不了了,停止之后发现在startup_stm32f40_41xxx.s中 初始化代码: TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE); ///ʹÄÜTIM3ʱÖÓ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_TIM10_IRQn; //¶¨Ê±Æ÷3ÖÐ¶Ï NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x00; //ÇÀÕ¼ÓÅÏȼ¶1 NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x00; //×ÓÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructure); TIM_TimeBaseInitStructure.TIM_Period = 10000-1; //×Ô¶¯ÖØ×°ÔØÖµ TIM_TimeBaseInitStructure.TIM_Prescaler= 8400-1; //¶¨Ê±Æ÷·ÖƵ TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //ÏòÉϼÆÊýģʽ TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1; TIM_TimeBaseInitStructure.TIM_RepetitionCounter=0; TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);//³õʼ»¯TIM3 //TIM_ClearFlag(TIM1,TIM_FLAG_Update); TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE); //ÔÊÐí¶¨Ê±Æ÷3¸üÐÂÖÐ¶Ï TIM_Cmd(TIM1,ENABLE);

STM32 的 USART 使能USART_IT_RXNE进不了中断

# STM32 的 USART 使能USART_IT_RXNE进不了中断,USART_IT_TXE就能进 void USART_Configure() { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE ); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 |GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1); USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx |USART_Mode_Tx; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_Init(USART1,&USART_InitStructure); USART_Cmd(USART1,ENABLE); USART_ClearFlag(USART1,USART_FLAG_RXNE); USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);//USART_IT_TXE /* 中断*/ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//优先级分布 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_Init(&NVIC_InitStructure); } void USART1_IRQHandler(void) { u8 res; if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET) { USART_ClearFlag(USART1,USART_FLAG_RXNE); USART_ClearITPendingBit(USART1,USART_IT_RXNE); res = USART_ReceiveData(USART1); USART_SendData(USART1,res); } while (1) { USART_SendData(USART1,'C'); while(RESET == USART_GetFlagStatus(USART1,USART_FLAG_TXE)); } } // int main(void) { SystemInit(); USART_Configure(); delay(1000); while (1) { USART_SendData(USART1,'a'); while(RESET == USART_GetFlagStatus(USART1,USART_FLAG_TXE)); delay(1000); } }

stm32f103c8t6串口 usart1只能发送不能接受

这几天一直在搞毕设,需要通过串口用电脑控制单片机,用的是usart1,调了好几天,死活就是只能发送数据,不能接受数据,下面是我的配置函数和串口中断处理函数,求指导!!! //串口引脚初始化 void Init_Usart(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } //串口配置函数 void Usart_Configuration(uint32_t BaudRate) { USART_InitTypeDef USART_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); USART_InitStructure.USART_BaudRate =BaudRate ; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No ; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); USART_Cmd(USART1, ENABLE); } //串口中断处理函数 void USART1_IRQHandler(void) { uint8_t ReceiveDate; if(!(USART_GetITStatus(USART1,USART_IT_RXNE))) { USART_ClearITPendingBit(USART1,USART_IT_RXNE); ReceiveDate=USART_ReceiveData(USART1); printf("%d",(char *)ReceiveDate); printf("\n\r"); } } //串口中断NVIC配置函数 void Init_NVIC(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef VECT_TAB_RAM NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); } 调了好几天了,实在是高不出来了,求大神指导!!!!!!!跪谢!!

stm32f407 DMA接收、发送问题

进行串口收发时,可以发送数据,但是DMA无法读取数据,配置看了好几遍,不知道哪里出现了问题,特意贴个代码,希望大家帮忙看看 #include "stm32f4xx.h" #include "myconst.h" #include "myfunction.h" #include <stdio.h> #include "eeprom.h" extern uint8_t uploaddata[10]; extern uint8_t usart1_dma_received[55]; extern uint8_t usart1_dma_flag; //Óë´«¸ÐÐÅÏ¢°åͨÐŵĴ®¿Ú£ºPA9---TX; PA10---RX //½ÓÊÕ´«¸Ð°å·¢À´µÄ59¸ö×Ö½Ú£º3A+A3+±ÚÕÏ2¸ö×Ö½Ú+µçÁ¿2¸ö×Ö½Ú+¹ßµ¼12¸ö×Ö½Ú+GPS39¸ö×Ö½Ú+Éî¶È2¸ö×Ö½Ú //Ïò´«¸Ð°å·¢ËÍË®ÖÊÐÅÏ¢£º10¸ö×Ö½Ú£ºA4+phÖµ2¸ö×Ö½Ú+µçµ¼ÂÊ3¸ö×Ö½Ú+ζÈ2¸ö×Ö½Ú+0A+0D; void USART1_Configuration(void) { USART_InitTypeDef USART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; DMA_InitTypeDef DMA_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1); USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_Init(USART1, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); USART_ClearFlag(USART1, USART_FLAG_TC); USART_Cmd(USART1, ENABLE); /*DMA·¢ËÍÅäÖÃ*/ DMA_DeInit(DMA2_Stream7); DMA_StructInit( &DMA_InitStructure); DMA_InitStructure.DMA_Channel = DMA_Channel_4; DMA_InitStructure.DMA_PeripheralBaseAddr =USART1_DR_Base; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)0; DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; DMA_InitStructure.DMA_BufferSize = 8; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream7, &DMA_InitStructure); DMA_ITConfig(DMA2_Stream7, DMA_IT_TC, ENABLE); USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); DMA_ClearITPendingBit(DMA2_Stream7, DMA_IT_TCIF7); /*DMA ½ÓÊÕÊý¾ÝÉèÖÃ*/ DMA_DeInit(DMA2_Stream5); DMA_StructInit(&DMA_InitStructure); DMA_InitStructure.DMA_Channel = DMA_Channel_4; //Ñ¡ÔñChannel_5 DMA_InitStructure.DMA_PeripheralBaseAddr =USART1_DR_Base; //Êý¾Ý´«ÊäµÄÍâÉèÊ×µØÖ·£¬Ïê½â¼ûÉÏ DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)(&usart1_dma_received[0]); //×Ô¼º¶¨Òå´ý·¢ËÍÊý×éµÄÊ×µØÖ·£¬ÒªÇ¿ÖÆת»»Îª32λ DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; //Êý¾Ý´«Êä·½ÏòÑ¡ÔñΪÄÚ´æ<-ÍâÉè DMA_InitStructure.DMA_BufferSize =8; //´«ÊäÊý¾Ý´óСΪ8£¬µ¥Î»ÓÉÒÔÏÂÈ·¶¨£¬´óСҪÅäºÏ¶¨ÒåµÄÊý×éÀàÐͺÍÍâÉèÊý¾ÝÀàÐÍ DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //ÍâÉèµØÖ·¼Ä´æÆ÷×Ô¶¯Ôö¼Ó½ûÖ¹£¬ÒòΪÕâÀïÖ»Óõ½ÁËDRÊý¾Ý¼Ä´æÆ÷ DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //ÄÚ´æµØÖ·×ÔÔöÔÊÐí£¬ÒòΪҪ¶ÁÈ¡Ò»¸öÊý×é DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //ÍâÉèµÄÊý¾Ý´óС£¬ÒòΪUSART6_DRÊý¾Ý¼Ä´æÆ÷Ϊ8Ϊ£¬¹ÊÑ¡Byte DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //ÕâÀïҲѡByte DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //DMA´«ÊäģʽΪNormal£¬Èç¹ûΪCircular,½«»áÑ­»·´«Êä DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; //ÓÅÏȼ¶ÎªHigh DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream5, &DMA_InitStructure); //DMA_ITConfig(DMA2_Stream5, DMA_IT_TC, ENABLE); DMA_ClearITPendingBit(DMA2_Stream5, DMA_IT_TCIF5); USART_DMACmd(USART1,USART_DMAReq_Rx, ENABLE); DMA_Cmd(DMA2_Stream5, ENABLE); } /*dma ½ÓÊÕÖжÏ*/ void DMA2_Stream5_IRQHandler(void) { if (DMA_GetITStatus(DMA2_Stream5, DMA_IT_TCIF5) != RESET) { DMA_Cmd(DMA2_Stream5, DISABLE); DMA_ClearITPendingBit(DMA2_Stream5, DMA_IT_TCIF5); USART_DMACmd(USART1, USART_DMAReq_Rx, DISABLE); usart1_dma_flag=1; } } //USART1 DMA ·¢ËÍÖÐ¶Ï void DMA2_Stream7_IRQHandler(void) { if (DMA_GetITStatus(DMA2_Stream7, DMA_IT_TCIF7) != RESET) //·¢ËÍÍê³É { DMA_ClearITPendingBit(DMA2_Stream7, DMA_IT_TCIF7); USART_DMACmd(USART1, USART_DMAReq_Tx, DISABLE); DMA_Cmd(DMA2_Stream7, DISABLE); } } void UASRT1_DMA_Senddata(u32 par,u16 ndtr) { DMA_Cmd(DMA2_Stream7, DISABLE); DMA2_Stream7->M0AR = (uint32_t)(par); DMA2_Stream7->NDTR = ndtr; DMA_Cmd(DMA2_Stream7, ENABLE); USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); } void USART1_IRQHandler(void) { if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //ÅжÏΪ½ÓÊÕÖÐ¶Ï { // uint8_t Received; // float angle_temp=0; // Received = USART_ReceiveData(USART1); // USART_SendData(USART1,Received); // usart1_dma_flag=1; USART_ClearITPendingBit(USART1,USART_IT_RXNE); } } int main(void) { while(1) if(usart1_dma_flag==1)//Êý¾Ý½ÓÊÜ { //......... DMA_Cmd(DMA2_Stream5, ENABLE); USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE); } } void NVIC_Config() { NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USARTx Interrupt */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); ////// NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); ////// NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); ////// NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //ǶÌ×ÓÅÏȼ¶·Ö×éΪ 1 NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream5_IRQn; //ǶÌ×ͨµÀΪDMA2_Stream7_IRQn NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //ÇÀÕ¼ÓÅÏȼ¶Îª 1 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //ÏìÓ¦ÓÅÏȼ¶Îª 0 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ͨµÀÖжÏʹÄÜ NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //ǶÌ×ÓÅÏȼ¶·Ö×éΪ 1 NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream7_IRQn; //ǶÌ×ͨµÀΪDMA2_Stream7_IRQn NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //ÇÀÕ¼ÓÅÏȼ¶Îª 1 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 4; //ÏìÓ¦ÓÅÏȼ¶Îª 0 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ͨµÀÖжÏʹÄÜ NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); ////// NVIC_InitStructure.NVIC_IRQChannel = USART6_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //ǶÌ×ÓÅÏȼ¶·Ö×éΪ 1 NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream1_IRQn; //ǶÌ×ͨµÀΪDMA2_Stream7_IRQn NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //ÇÀÕ¼ÓÅÏȼ¶Îª 1 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 6; //ÏìÓ¦ÓÅÏȼ¶Îª 0 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ͨµÀÖжÏʹÄÜ NVIC_Init(&NVIC_InitStructure); // // NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); // ÇÀռʽÓÅÏȼ¶±ð // NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;//Ö¸¶¨ÖжÏÔ´ // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;// Ö¸¶¨ÏìÓ¦ÓÅÏȼ¶±ð1 // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // NVIC_Init(&NVIC_InitStructure); // NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); // ÇÀռʽÓÅÏȼ¶±ð NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn;//Ö¸¶¨ÖжÏÔ´ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;// Ö¸¶¨ÏìÓ¦ÓÅÏȼ¶±ð1 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); // ÇÀռʽÓÅÏȼ¶±ð NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }

stm32 PVD掉电检测,进不了中断

芯片是stm32f103C8T6,PVD掉电检测,中断服务函数是通过串口发送数据。可是并没有发送,不知道是没有进入中断,还是进入了中断,但电压值过低,串口发送数据失败。求大神看看,写了好久没解决问题。代码如下: void PVD_Init(void) { SystemInit(); EXTI_InitTypeDef EXTI_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);//PWRʹÄÜ /* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and falling edges */ EXTI_ClearITPendingBit(EXTI_Line16); EXTI_InitStructure.EXTI_Line = EXTI_Line16; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } void PVD_NVIC(void) { NVIC_InitTypeDef NVIC_InitStructure; /* Configure one bit for preemption priority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); /* Enable the PVD Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void PVD_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line16) != RESET) { GPIO_SetBits(GPIOA,GPIO_Pin_1); start();//串口发送数据 EXTI_ClearITPendingBit(EXTI_Line16); } } int main() { ..... PWR_PVDLevelConfig(PWR_PVDLevel_2V9); PWR_PVDCmd(ENABLE); PVD_Init(); PVD_NVIC(); .... while(1) { ; } }

使用keil进行软件仿真时怎样进入外部中断?

现在我可以进入主函数等进行单步仿真等操作,但是不知道应该怎么进入外部中断的函数,请大神指点~ 主函数: ``` #include "stm32f4xx.h" #include "led.h" #include "bit_operation.h" #include "Systick.h" #include "beep.h" #include "key.h" #include "exti.h" int main() { NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); My_EXTI_Init(); BEEP_Init(); KEY_Init(); SysTick_Init(168); //系统时钟为168M RCC_HSE_Config(8,336,2,7); LED_Init(); while(1) { delay_nms(100); led1=!led1; } } ``` 这是我进行的外部中断的设置: ``` NVIC_InitTypeDef NVIC_InitStruct; EXTI_InitTypeDef EXTI_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource0); NVIC_InitStruct.NVIC_IRQChannel=EXTI0_IRQn; NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=2; NVIC_InitStruct.NVIC_IRQChannelSubPriority=2; NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStruct); EXTI_InitStruct.EXTI_Line=EXTI_Line0; EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Rising; EXTI_InitStruct.EXTI_LineCmd=ENABLE; EXTI_Init(&EXTI_InitStruct); ``` 最后是对应的中断服务函数: ``` void EXTI0_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line0)==1) { delay_nms(10); if(KEY_UP==1) { led2=0; } } EXTI_ClearITPendingBit(EXTI_Line0); } ```

STM32串口如何实现一个发数据,另外一个接收数据

在keil5在编程环境下,想要实现的功能是:利用中断,让串口四接收数据,串口一发送数据 部分代码如下: int main(void) { //初始化USART1和UART4 配置模式为 115200 8-N-1,通过USART1发送数据,通过UART4接收数据 Debug_USART1_Config(); Debug_UART4_Config(); while(1) { } } 、、、、、、、、、中断函数如下、、、、、、、、、 相关宏定义 #define DEBUG_R_USART_IRQHandler UART4_IRQHandler #define DEBUG_R_USART_IRQ UART4_IRQn //串口四的中断程序:用于接收数据 void DEBUG_R_USART_IRQHandler(void) { if(USART_GetITStatus(UART4,USART_IT_RXNE)!=RESET) { USART_ClearFlag(UART4,USART_IT_RXNE); // USART_ClearITPendingBit(UART4,USART_IT_RXNE); //清除中断标志 ucTemp = USART_ReceiveData(UART4); } } //串口一的中断程序:用于发送数据 void DEBUG_T_USART_IRQHandler(void) { if(USART_GetITStatus(USART1,USART_IT_RXNE)!=RESET) { USART_ClearFlag(USART1,USART_IT_RXNE); //清除标志 // USART_ClearITPendingBit(USART1,USART_IT_RXNE); //清除中断预处理位 USART_SendData(USART1,ucTemp); } } 、、、、、、、、中断函数的配置、、、、、、、、、 //接收串口引脚定义 /*******************************************************/ #define DEBUG_USART UART4 #define DEBUG_USART_CLK RCC_APB1Periph_UART4 #define DEBUG_USART_BAUDRATE 115200 //串口波特率 #define DEBUG_USART_RX_GPIO_PORT GPIOA #define DEBUG_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOA #define DEBUG_USART_RX_PIN GPIO_Pin_1 #define DEBUG_USART_RX_AF GPIO_AF_UART4 #define DEBUG_USART_RX_SOURCE GPIO_PinSource1 #define DEBUG_USART_TX_GPIO_PORT GPIOA #define DEBUG_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOA #define DEBUG_USART_TX_PIN GPIO_Pin_0 #define DEBUG_USART_TX_AF GPIO_AF_UART4 #define DEBUG_USART_TX_SOURCE GPIO_PinSource0 #define DEBUG_R_USART_IRQHandler UART4_IRQHandler #define DEBUG_R_USART_IRQ UART4_IRQn /************************************************************/ //发送串口引脚定义 /*******************************************************/ #define DEBUG_T_USART USART1 #define DEBUG_T_USART_CLK RCC_APB2Periph_USART1 #define DEBUG_T_USART_BAUDRATE 115200 //串口波特率 #define DEBUG_T_USART_RX_GPIO_PORT GPIOA #define DEBUG_T_USART_RX_GPIO_CLK RCC_AHB1Periph_GPIOA #define DEBUG_T_USART_RX_PIN GPIO_Pin_10 #define DEBUG_T_USART_RX_AF GPIO_AF_USART1 #define DEBUG_T_USART_RX_SOURCE GPIO_PinSource10 #define DEBUG_T_USART_TX_GPIO_PORT GPIOA #define DEBUG_T_USART_TX_GPIO_CLK RCC_AHB1Periph_GPIOA #define DEBUG_T_USART_TX_PIN GPIO_Pin_9 #define DEBUG_T_USART_TX_AF GPIO_AF_USART1 #define DEBUG_T_USART_TX_SOURCE GPIO_PinSource9 #define DEBUG_T_USART_IRQHandler USART1_IRQHandler #define DEBUG_T_USART_IRQ USART1_IRQn /************************************************************/ static void NVIC_Configuration(void) //串口四的中断参数的配置 { NVIC_InitTypeDef NVIC_InitStructure; /* 嵌套向量中断控制器组选择 */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); /* 配置UART4为中断源 */ NVIC_InitStructure.NVIC_IRQChannel = DEBUG_R_USART_IRQ; /* 抢断优先级为1 */ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; /* 子优先级为1 */ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; /* 使能中断 */ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /* 初始化配置NVIC */ NVIC_Init(&NVIC_InitStructure); } static void T_NVIC_Configuration(void) //串口一的中断参数的配置 { NVIC_InitTypeDef NVIC_InitStructure; /* 嵌套向量中断控制器组选择 */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); /* 配置USART1为中断源 */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; /* 抢断优先级为1 */ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; /* 子优先级为1 */ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; /* 使能中断 */ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /* 初始化配置NVIC */ NVIC_Init(&NVIC_InitStructure); } 、、、、、、、、有关串口的配置、、、、、、、、 void Debug_UART4_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_AHB1PeriphClockCmd(DEBUG_USART_RX_GPIO_CLK|DEBUG_USART_TX_GPIO_CLK,ENABLE); /* 使能 USART 时钟 */ RCC_APB1PeriphClockCmd(DEBUG_USART_CLK, ENABLE); /* GPIO初始化 */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* 配置Tx引脚为复用功能 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = DEBUG_USART_TX_PIN ; GPIO_Init(DEBUG_USART_TX_GPIO_PORT, &GPIO_InitStructure); /* 配置Rx引脚为复用功能 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = DEBUG_USART_RX_PIN; GPIO_Init(DEBUG_USART_RX_GPIO_PORT, &GPIO_InitStructure); /* 连接 PXx 到 USARTx_Tx*/ GPIO_PinAFConfig(DEBUG_USART_RX_GPIO_PORT,DEBUG_USART_RX_SOURCE,DEBUG_USART_RX_AF); /* 连接 PXx 到 USARTx__Rx*/ GPIO_PinAFConfig(DEBUG_USART_TX_GPIO_PORT,DEBUG_USART_TX_SOURCE,DEBUG_USART_TX_AF); /* 配置串DEBUG_USART 模式 */ /* 波特率设置:DEBUG_USART_BAUDRATE */ USART_InitStructure.USART_BaudRate = DEBUG_USART_BAUDRATE; /* 字长(数据位+校验位):8 */ USART_InitStructure.USART_WordLength = USART_WordLength_8b; /* 停止位:1个停止位 */ USART_InitStructure.USART_StopBits = USART_StopBits_1; /* 校验位选择:不使用校验 */ USART_InitStructure.USART_Parity = USART_Parity_No; /* 硬件流控制:不使用硬件流 */ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; /* USART模式控制:同时使能接收和发送 */ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* 完成USART初始化配置 */ USART_Init(DEBUG_USART, &USART_InitStructure); /* 嵌套向量中断控制器NVIC配置 */ NVIC_Configuration(); /* 使能串口接收中断 */ USART_ITConfig(DEBUG_USART, USART_IT_RXNE, ENABLE); //使能了接收中断,那么ORE中断也同时被开启了。 /* 使能串口 */ USART_Cmd(DEBUG_USART, ENABLE); } void Debug_USART1_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE); /* 使能 USART 时钟 */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); /* GPIO初始化 */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* 配置Tx引脚为复用功能 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = DEBUG_USART_TX_PIN ; GPIO_Init(DEBUG_T_USART_TX_GPIO_PORT, &GPIO_InitStructure); /* 配置Rx引脚为复用功能 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = DEBUG_T_USART_RX_PIN; GPIO_Init(DEBUG_T_USART_RX_GPIO_PORT, &GPIO_InitStructure); /* 连接 PXx 到 USARTx_Tx*/ GPIO_PinAFConfig(DEBUG_T_USART_RX_GPIO_PORT,DEBUG_T_USART_RX_SOURCE,DEBUG_T_USART_RX_AF); /* 连接 PXx 到 USARTx__Rx*/ GPIO_PinAFConfig(DEBUG_T_USART_TX_GPIO_PORT,DEBUG_T_USART_TX_SOURCE,DEBUG_T_USART_TX_AF); /* 配置串DEBUG_USART 模式 */ /* 波特率设置:DEBUG_USART_BAUDRATE */ USART_InitStructure.USART_BaudRate = DEBUG_T_USART_BAUDRATE; /* 字长(数据位+校验位):8 */ USART_InitStructure.USART_WordLength = USART_WordLength_8b; /* 停止位:1个停止位 */ USART_InitStructure.USART_StopBits = USART_StopBits_1; /* 校验位选择:不使用校验 */ USART_InitStructure.USART_Parity = USART_Parity_No; /* 硬件流控制:不使用硬件流 */ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; /* USART模式控制:同时使能接收和发送 */ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* 完成USART初始化配置 */ USART_Init(DEBUG_T_USART, &USART_InitStructure); /* 嵌套向量中断控制器NVIC配置 */ T_NVIC_Configuration(); /* 使能串口接收中断 */ USART_ITConfig(DEBUG_T_USART, USART_IT_RXNE, ENABLE); /* 使能串口 */ USART_Cmd(DEBUG_T_USART, ENABLE); } 未解决:串口一和串口四都可以单独收发,但是我想要实现一个串口收,另外一个串口发的功能,,,,,,,,求助啊,,,,,,试了好多可能性了

STM32为什么用串口接收数据不全,时常丢失?

``` ```#include "stm32f10x.h" #include "usart.h" #include "delay.h" void My_USART1_Init(void) { GPIO_InitTypeDef GPIO_InitStrue; USART_InitTypeDef USART_InitStrue; NVIC_InitTypeDef NVIC_InitStrue; //①使能GPIOA和串口1 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //②初始化GPIOA两个引脚 GPIO_InitStrue.GPIO_Mode=GPIO_Mode_AF_PP; GPIO_InitStrue.GPIO_Pin=GPIO_Pin_9; GPIO_InitStrue.GPIO_Speed=GPIO_Speed_10MHz; GPIO_Init(GPIOA,&GPIO_InitStrue); GPIO_InitStrue.GPIO_Mode=GPIO_Mode_IN_FLOATING; GPIO_InitStrue.GPIO_Pin=GPIO_Pin_10; GPIO_InitStrue.GPIO_Speed=GPIO_Speed_10MHz; GPIO_Init(GPIOA,&GPIO_InitStrue); //③串口初始化 //波特率 USART_InitStrue.USART_BaudRate=115200; //硬件控制 USART_InitStrue.USART_HardwareFlowControl=USART_HardwareFlowControl_None; USART_InitStrue.USART_Mode=USART_Mode_Rx|USART_Mode_Tx; //奇偶验证 USART_InitStrue.USART_Parity=USART_Parity_No; //停止位 USART_InitStrue.USART_StopBits=USART_StopBits_1; //字长 USART_InitStrue.USART_WordLength=USART_WordLength_8b; USART_Init(USART1,&USART_InitStrue); //串口使能 USART_Cmd(USART1,ENABLE);//③ USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);//开启接受中断 USART_ITConfig(USART1,USART_IT_ORE,ENABLE);//开启溢出中断 //初始化中断 NVIC_InitStrue.NVIC_IRQChannel=USART1_IRQn; NVIC_InitStrue.NVIC_IRQChannelCmd=ENABLE; NVIC_InitStrue.NVIC_IRQChannelPreemptionPriority=1; NVIC_InitStrue.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_InitStrue); } u8 usart_buf[4][USART_REC_LEN];//接收缓冲,最大USART_REC_LEN个字节 static volatile u16 count=0;//接收状态标记 static volatile int p=0; void USART1_IRQHandler(void) { if(USART_GetITStatus(USART1,USART_IT_RXNE)!=RESET)//开启接收中断 { USART_ClearITPendingBit(USART1,USART_IT_RXNE);//清除标志中断位 p = (count / USART_REC_LEN) % 4; usart_buf[p][count % USART_REC_LEN] = USART_ReceiveData(USART1); count++; } } int main(void) { //要使用中断,先要中断分组,一般在主函数的开头 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); My_USART1_Init(); delay_init(); while(1){ if(count > 0){ if(count % 256 == 0){ for(int i = 0; i < 256; i++){ USART_SendData(USART1,usart_buf[p][i]); while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET); } printf("\r\n\r\n"); delay_ms(100); } } }; } ![图片说明](https://img-ask.csdn.net/upload/201910/31/1572495626_268037.png)

我在程序里添加了四个中断函数,为什么火焰报警器和定时器的中断就能触发,按键的中断就触发不了

#include "Exti.h" #include "./led/bsp_led.h" static void NVIC_Configuaration2(void) { NVIC_InitTypeDef NVIC_InitStructure; //中断分组 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //主优先级 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2; //子优先级 NVIC_InitStructure.NVIC_IRQChannelSubPriority=1; //使能中断 NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; //中断源火焰传感器 NVIC_InitStructure.NVIC_IRQChannel=FIRE_INT_EXTI_IRQ ; NVIC_Init(&NVIC_InitStructure); } void EXTI_Fire_Config(void) { EXTI_InitTypeDef EXTI_InitStructure; Fire_GPIO_Config(); NVIC_Configuaration2(); //火焰传感器的EXTI配置 //选择EXTI的信号源为火焰传感器 GPIO_EXTILineConfig(FIRE_INT_EXTI_PORTSOURCE,FIRE_INT_EXTI_PINSOURCE); EXTI_InitStructure.EXTI_Line=FIRE_INT_EXTI_LINE ; //EXTI模式为中断 EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //上升沿触发 EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //使能EXTI EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } void Fire_GPIO_Config() { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO,ENABLE); GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOB,&GPIO_InitStructure); } 这是火焰传感器的中断配置 void FIRE_IRQHandler (void) { if(EXTI_GetITStatus(FIRE_INT_EXTI_LINE)!=RESET) { Fire_Flag=1; EXTI_ClearITPendingBit(FIRE_INT_EXTI_LINE); } 这是火焰传感器的中断函数 void FireAlarm(void) { if(Fire_Flag==1) { Fire_Flag=0; OLED_Init(); OLED_ShowStr(0,10,(unsigned char*)"Fire Warning",2); while(1) { GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(200); GPIO_SetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(200); GPIO_ResetBits(LED3_GPIO_PORT,LED3_GPIO_PIN); Delay_ms(200); GPIO_SetBits(LED3_GPIO_PORT,LED3_GPIO_PIN); } } } 这是触发火焰传感器中断后要执行的函数 static void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; /* 配置NVIC为优先级组1 */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); /* 配置中断源:按键1 */ NVIC_InitStructure.NVIC_IRQChannel = KEY1_INT_EXTI_IRQ; /* 配置抢占优先级 */ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; /* 配置子优先级 */ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; /* 使能中断通道 */ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* 配置中断源:按键2,其他使用上面相关配置 */ NVIC_InitStructure.NVIC_IRQChannel = KEY2_INT_EXTI_IRQ; NVIC_Init(&NVIC_InitStructure); } 这是按键的NVIC配置 void EXTI_Key_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; /*开启按键GPIO口的时钟*/ RCC_APB2PeriphClockCmd(KEY1_INT_GPIO_CLK|KEY2_INT_GPIO_CLK,ENABLE); /* 配置 NVIC 中断*/ NVIC_Configuration(); /*--------------------------KEY1配置-----------------------------*/ /* 选择按键用到的GPIO */ GPIO_InitStructure.GPIO_Pin = KEY1_INT_GPIO_PIN; /* 配置为浮空输入 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(KEY1_INT_GPIO_PORT, &GPIO_InitStructure); /* 选择EXTI的信号源 */ GPIO_EXTILineConfig(KEY1_INT_EXTI_PORTSOURCE, KEY1_INT_EXTI_PINSOURCE); EXTI_InitStructure.EXTI_Line = KEY1_INT_EXTI_LINE; /* EXTI为中断模式 */ EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; /* 上升沿中断 */ EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; /* 使能中断 */ EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } 按键1的EXTI配置 void KEY1_IRQHandler(void) { if(EXTI_GetITStatus(KEY1_INT_EXTI_LINE)!=RESET) { RESET_Flag=1; EXTI_ClearITPendingBit(KEY1_INT_EXTI_LINE); } } 按键1的中断配置 void RESETs(void) { if(RESET_Flag==1) { RESET_Flag=0; /* 关闭所有led灯 */ GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); /* 关闭所有led灯 */ GPIO_SetBits(LED2_GPIO_PORT, LED2_GPIO_PIN); /* 关闭所有led灯 */ GPIO_SetBits(LED3_GPIO_PORT, LED3_GPIO_PIN); } } 这是进入按键1中断之后再应该执行的函数

stm32延时函数可行和不可行

# 1. 可行的延时 #MeLED.c ``` include "MELED.h" void LED_TIM_Config(void) { TIM_TimeBaseInitTypeDef LED_TIM_Struct; TIM_OCInitTypeDef TIM_OCInitConfig; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); TIM_DeInit(TIM4); //GPIO_PinRemapConfig(GPIO_Remap_TIM4, ENABLE); TIM_OCInitConfig.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitConfig.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitConfig.TIM_OCPolarity = TIM_OCPolarity_Low; LED_TIM_Struct.TIM_Prescaler = (36000 - 1); LED_TIM_Struct.TIM_Period = 2 - 1; LED_TIM_Struct.TIM_ClockDivision = TIM_CKD_DIV1; LED_TIM_Struct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &LED_TIM_Struct); TIM_ClearFlag(TIM4, TIM_FLAG_Update); TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE); TIM_OC1PreloadConfig(TIM4, ENABLE); TIM_Cmd(TIM4, ENABLE); } ``` ``` void LED_NVIC_Config(void) { NVIC_InitTypeDef LED_NVIC_Struct; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); LED_NVIC_Struct.NVIC_IRQChannel = TIM4_IRQn; LED_NVIC_Struct.NVIC_IRQChannelPreemptionPriority = 0;//抢占优先级 LED_NVIC_Struct.NVIC_IRQChannelSubPriority = 0;//响应优先级 LED_NVIC_Struct.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&LED_NVIC_Struct); } ``` int i = 0;//注意该变量是定义在MeLED.c文件中的 ``` void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4,TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIM4, TIM_IT_Update); i++; } } ``` ``` void My_Systick_Delay(uint32_t nTime) { i = 0; while(nTime != i); } ``` #MeLED.h ``` #ifndef __MELED_H #define __MELED_H #include "stm32f10x.h" #include "led.h" #include "Oper_System_Delay.h" void MELED_Init(void); void MELED_PWM_Init(void); void LED_TIM_Config(void); void LED_NVIC_Config(void); void TIM4_IRQHandler(void); void My_Systick_Delay(uint32_t nTime); #endif ``` #main.c ``` #include "stm32f10x.h" #include "usart.h" #include "led.h" #include "RTC_Time.h" #include <stdio.h> #include "MeLED.h" #include "Delay.h" ``` ``` int main(void) { while(1) { My_Systick_Delay(1000); printf("Delay over\n"); } } ``` #2.不可行的延时(我想知道为什么不可行?) #Delay.c ``` #include "Delay.h" void My_Systick_Delay(uint32_t nTime) { Attain_delay = 0; while(nTime != Attain_delay);//程序会不停的在这里循环 } ``` #Delay.h ``` #ifndef __Delay_H #define __Delay_H #include "stm32f10x.h" #include "stm32f10x_tim.h" #include "stm32f10x_it.h" #include "core_cm3.h" #include "Oper_System_Delay.h" #endif ``` #Oper_System_Delay.h ``` #ifndef __Oper_System_Delay_H #define __Oper_System_Delay_H #include "stm32f10x.h" #include "stm32f10x_tim.h" #include "stm32f10x_it.h" static uint32_t Attain_delay; //void Oper_System_Delay(); #endif ``` #MeLED.c ``` void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4,TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIM4, TIM_IT_Update); Attain_delay++; } } ``` 所以第2点有人知道为什么不可行吗?最好可以提供第1和第2的差别在哪?

STM32F407 UART5没反应,波形也不对

#include "usart.h" #include "stm32f4xx.h" #define RS485tX GPIO_SetBits(GPIOE,GPIO_Pin_1);//1 拉高 #define RS485rX GPIO_ResetBits(GPIOE, GPIO_Pin_1);//0 拉低 void uart_init(void) { USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE); GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_UART5); //UART5_RX GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_UART5); //UART5_TX GPIO_PinAFConfig(GPIOE, GPIO_PinSource1, GPIO_AF_UART5); //uart5_DE GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOE, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(UART5, &USART_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_Cmd(UART5, ENABLE); USART_ITConfig(UART5, USART_IT_RXNE, ENABLE); } static void delay(unsigned int dl) { unsigned int i,y; for(i = 0; i < 500; i++) { for(y = 0; y < dl; y++); } } void UART5_IRQHandler(void) { uint8_t x,y,z; uint16_t checksum1,checksum2; if(USART_GetITStatus(UART5, USART_IT_RXNE) != RESET) { x=USART_ReceiveData(UART5); USART_SendData(UART5,x); } } void uartsend(int ch) { RS_485tX; delay(100); while(RESET == USART_GetFlagStatus(UART5,USART_FLAG_TXE)); USART_SendData(UART5, (uint8_t) ch); RS485rX; delay(100); } 用的是STM32F407的片子,现在接受和发送数据都没有,这是为什么呢?

stm32F4DISCOVERY串口通信问题

void RCC_Configuration(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); } void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Configure USART Tx and Rx as alternate function push-pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin =GPIO_Pin_9; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_USART3); GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_USART3); } void USART_Configuration(void) { USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength =USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No ; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART3,&USART_InitStructure); /* Configure USART1 basic and asynchronous paramters */ //USART_ITConfig(USART3,USART_IT_RXNE,ENABLE); USART_ITConfig(USART3,USART_IT_TXE,ENABLE); USART_Cmd(USART3, ENABLE); /* Enable USART1 */ USART_ClearITPendingBit(USART3,USART_IT_TC); } void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure;//????? NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } int main(void) { RCC_Configuration(); GPIO_Configuration(); NVIC_Configuration(); USART_Configuration(); while(1); } volatile char StringLoop[] = "The quick brown fox jumps over the lazy dog"; void USART3_IRQHandler(void) { static int tx_index = 0; // static int rx_index = 0; if (USART_GetITStatus(USART3, USART_IT_TXE) != RESET) // Transmit the string in a loop { USART_ClearITPendingBit(USART3, USART_IT_TXE); USART_SendData(USART3, StringLoop[tx_index++]); if (tx_index >= (sizeof(StringLoop) - 1)) tx_index = 0; } } 就是这个程序为什么会不停的发送数据,PC接收端一直在接收,不是清除了标志位吗,想问问大家啊

使用stm32f1通过串口接收上位机信息产生中断来控制电机,但是中断打不开,想请大佬看看是为什么?

主要思路是在串口通信助手中发送“1”,然后串口接收中断打开,在串口通信助手中打印“中断开始”的信息。但是这句“中断开始”信息没有显示,想请大佬看看shi'wei'shen'm usart.c ``` #include "stm32f10x.h" #include "usart.h" //已检查 无误 static void NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn ; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_Init(&NVIC_InitStructure); } //串口初始化函数已检查 无误 void USART1_Init(void) { USART_InitTypeDef USART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; //看io口和usart的时钟 //RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA,ENABLE); 函数用错了 //RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //初始化串口USART1输入输出的io口 //输出 推挽复用输出 PA9 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //初始化PA9 GPIO_Init( GPIOA , &GPIO_InitStructure ); //输出 浮空输入 PA10 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //初始化PA10 GPIO_Init( GPIOA , &GPIO_InitStructure ); //初始化串口 USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Parity = USART_Parity_No; USART_Init(USART1,&USART_InitStructure); //串口中断优先级配置 NVIC_Config(); //串口接收中断 因为是接受上位机消息后驱动电机转动,所以使用接受中断 USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //串口使能 USART_Cmd( USART1,ENABLE); } /* 使用串口发送一个字节 */ void USART_SendByte(USART_TypeDef* pUSARTx,uint16_t Data) { USART_SendData( pUSARTx, Data); while( USART_GetFlagStatus( pUSARTx,USART_FLAG_TXE) == RESET); } /* 发送字符串(来自野火教程) */ void USART_SendStr( USART_TypeDef* pUSARTx , uint8_t *str) { uint8_t i=0; do { USART_SendByte( pUSARTx, *(str+i)); i++; }while( *(str+i) != '\0' ); while( USART_GetFlagStatus( pUSARTx,USART_FLAG_TC) == RESET); } ///重定向c库函数printf到串口,重定向后可使用printf函数 int fputc(int ch, FILE *f) { /* 发送一个字节数据到串口 */ USART_SendData(USART1, (uint8_t) ch); /* 等待发送完毕 */ while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); return (ch); } ///重定向c库函数scanf到串口,重写向后可使用scanf、getchar等函数 int fgetc(FILE *f) { /* 等待串口输入数据 */ while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET); return (int)USART_ReceiveData(USART1); } ``` usart.h ``` #ifndef __USART_H #define __USART_H #include "stm32f10x.h" #include <stdio.h> void USART1_Init(void); void Usart_SendByte(USART_TypeDef* pUSARTx, uint8_t data); void Usart_SendStr(USART_TypeDef* pUSARTx, uint8_t *str); #endif /* __USART_H */ ``` main.c ``` #include "stm32f10x.h" #include "moto.h" #include "usart.h" int main(void) { USART1_Init(); USART_SendStr( USART1 , "000\n"); //USART1_Init(); while(1){} } ``` 中断服务函数 ``` #include "stm32f10x_it.h" #include "usart.h" u8 Start_Flag=1; //电机启动/锁定标志 u16 Pluse_High=10; //脉冲高电平中断次数 1->10us u16 Pluse_Period=200;//脉冲周期中断次数 (转速) //脉冲中断服务函数------------------------------------------------------------ u32 TimeCount=0;//进中断计数 u16 a=0; void SysTick_Handler(void) { } void USART_IT_Handler(void) { //USART_SendStr( USART1 , "test\n"); if(USART_GetITStatus( USART1 ,USART_IT_RXNE)!=RESET) { printf("中断开始\n");//这句信息在串口通信助手中不显示 while(1) { if( USART_ReceiveData(USART1) == 1 ); break; } GPIO_SetBits(GPIOE,GPIO_Pin_5); while(a>1000)//让方向信号的输出略大于脉冲信号 {a++;} DJ_Init(); while(1){TIM4_Int_Init(10-1,84-1);} } } ```

STM32 SPI2使用DMA接收,DMA接收完成后不进DMA中断???

//Configuration SPI2 of CCPU2MCU RCC_AHB1PeriphClockCmd(PROTOCOL_SPI_PORT_CLK,ENABLE); //使能GPIO B口的时钟 RCC_APB1PeriphClockCmd(PROTOCOL_SPI_CLK, ENABLE); //使能SPI2 时钟 GPIO_PinAFConfig(PROTOCOL_SPI_CS_PORT, PROTOCOL_SPI_CS_PIN_SRC, GPIO_AF_SPI2); GPIO_PinAFConfig(PROTOCOL_SPI_SCK_PORT, PROTOCOL_SPI_SCK_PIN_SRC, GPIO_AF_SPI2); GPIO_PinAFConfig(PROTOCOL_SPI_MISO_PORT, PROTOCOL_SPI_MISO_PIN_SRC, GPIO_AF_SPI2); GPIO_PinAFConfig(PROTOCOL_SPI_MOSI_PORT, PROTOCOL_SPI_MOSI_PIN_SRC, GPIO_AF_SPI2); GPIO_InitStructure.GPIO_Pin = PROTOCOL_SPI_CS_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(PROTOCOL_SPI_CS_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PROTOCOL_SPI_SCK_PIN; GPIO_Init(PROTOCOL_SPI_SCK_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PROTOCOL_SPI_MOSI_PIN; GPIO_Init(PROTOCOL_SPI_MOSI_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = PROTOCOL_SPI_MISO_PIN; GPIO_Init(PROTOCOL_SPI_MISO_PORT, &GPIO_InitStructure); SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Slave; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 0x07; SPI_Init(SPI2, &SPI_InitStructure); SPI_Cmd(SPI2, ENABLE); // Configuration DMA1 DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); DMA_DeInit(DMA1_Stream3); //SPI2 Rx DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&(SPI2->DR)); DMA_InitStructure.DMA_Memory0BaseAddr = (u32)(&USART_RX_DMA_Buf[0]); DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 16384+6; //32768+6; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA1_Stream3, &DMA_InitStructure); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Rx, ENABLE); DMA_ClearITPendingBit(DMA1_Stream3,DMA_IT_TCIF3); DMA_ITConfig(DMA1_Stream3,DMA_IT_TC,ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannel = ENABLE; NVIC_Init(&NVIC_InitStructure); DMA_Cmd(DMA1_Stream3, ENABLE); // DMA Interrupt void DMA1_Stream3_IRQHandler(void) { unsigned int len; len = 0; if(DMA_GetITStatus(DMA1_Stream3, DMA_IT_TCIF3) != RESET) { DMA_ClearITPendingBit(DMA1_Stream3,DMA_IT_TCIF3); DMA_Cmd(DMA1_Stream3,DISABLE); spiRxFlag = 1; DMA_SetCurrDataCounter(DMA1_Stream3, 16384+6); DMA_Cmd(DMA1_Stream3, ENABLE); } }

STM32F4超声波串口打印不出来,大神求救

STM32F4超声波模块测距,想串口助手显示距离打印不出来,新手求救,不仅感谢。程序如下: cs.c #include "cs.h" #include "stm32f4xx.h" #include "delay.h" #include "usart.h" /*¼Ç¼¶¨Ê±Æ÷Òç³ö´ÎÊý*/ uint overcount=0; /*ÉèÖÃÖжÏÓÅÏȼ¶*/ void NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructer; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructer.NVIC_IRQChannelPreemptionPriority=0; NVIC_InitStructer.NVIC_IRQChannelSubPriority=0; NVIC_InitStructer.NVIC_IRQChannel=TIM2_IRQn; NVIC_InitStructer.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructer); } /*³õʼ»¯Ä£¿éµÄGPIOÒÔ¼°³õʼ»¯¶¨Ê±Æ÷TIM2*/ void CH_SR04_Init(void) { GPIO_InitTypeDef GPIO_InitStructer; TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructer; RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); /*TRIG´¥·¢ÐźÅ*/ GPIO_InitStructer.GPIO_Speed=GPIO_Speed_50MHz; GPIO_InitStructer.GPIO_Mode=GPIO_Mode_OUT; GPIO_InitStructer.GPIO_Pin=GPIO_Pin_8; GPIO_Init(GPIOB, &GPIO_InitStructer); /*ECOH»ØÏìÐźÅ*/ GPIO_InitStructer.GPIO_Mode=GPIO_Mode_IN; GPIO_InitStructer.GPIO_Pin=GPIO_Pin_9; GPIO_Init(GPIOB, & GPIO_InitStructer); /*¶¨Ê±Æ÷TIM2³õʼ»¯*/ TIM_DeInit(TIM2); TIM_TimeBaseInitStructer.TIM_Period=999;//¶¨Ê±ÖÜÆÚ1000 TIM_TimeBaseInitStructer.TIM_Prescaler=71; //·ÖƵϵÊý72 TIM_TimeBaseInitStructer.TIM_ClockDivision=TIM_CKD_DIV1; TIM_TimeBaseInitStructer.TIM_CounterMode=TIM_CounterMode_Up; //TIM_TimeBaseInitStructer.TIM_RepetitionCounter TIM_TimeBaseInit(TIM2,&TIM_TimeBaseInitStructer); TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);//¿ªÆô¸üÐÂÖÐ¶Ï NVIC_Config(); TIM_Cmd(TIM2,DISABLE);//¹Ø±Õ¶¨Ê±Æ÷ʹÄÜ } float Senor_Using(void) { float length=0,sum=0; u16 tim; uint i=0; /*²â5´ËÊý¾Ý¼ÆËãÒ»´Îƽ¾ùÖµ*/ while(i!=5) { PBout(8)=1; //À­¸ßÐźţ¬×÷Ϊ´¥·¢ÐźŠdelay_us(20); //¸ßµçƽÐźų¬¹ý10us PBout(8)=0; /*µÈ´ý»ØÏìÐźÅ*/ while(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_9)==RESET); TIM_Cmd(TIM2,ENABLE);//»ØÏìÐźŵ½À´£¬¿ªÆô¶¨Ê±Æ÷¼ÆÊý i+=1; //ÿ´ÎÊÕµ½Ò»´Î»ØÏìÐźÅ+1,ÊÕµ½5´Î¾Í¼ÆËã¾ùÖµ while(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_9)==SET);//»ØÏìÐźÅÏûʧ TIM_Cmd(TIM2,DISABLE);//¹Ø±Õ¶¨Ê±Æ÷ tim=TIM_GetCounter(TIM2);//»ñÈ¡¼ÆTIM2Êý¼Ä´æÆ÷ÖеļÆÊýÖµ£¬Ò»±ß¼ÆËã»ØÏìÐźŠlength=(tim+overcount*1000)/58.0;//ͨ¹ý»ØÏìÐźżÆËã¾àÀë sum=length+sum; TIM2->CNT=0; //½«TIM2¼ÆÊý¼Ä´æÆ÷µÄ¼ÆÊýÖµÇåÁã overcount=0; //ÖжÏÒç³ö´ÎÊýÇåÁã delay_ms(100); } length=sum/5; return length;//¾àÀë×÷Ϊº¯Êý·µ»ØÖµ } void TIM2_IRQHandler(void) { if(TIM_GetITStatus(TIM2,TIM_IT_Update)!=RESET) { TIM_ClearITPendingBit(TIM2,TIM_IT_Update);//Çå³ýÖжϱêÖ¾ overcount++; } } 主函数 #include "stm32f4xx.h" #include "usart.h" #include "delay.h" #include "cs.h" float ChangeDistance(int cout1) { float distance=0; printf("cou1=%d\n",cout1); distance=cout1/58.0; return distance; } int main(void) { NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//ÉèÖÃϵͳÖжÏÓÅÏȼ¶·Ö×é2 delay_init(168); //ÑÓʱ³õʼ»¯ uart_init(115200); //´®¿Ú³õʼ»¯²¨ÌØÂÊΪ115200 // int count=0; // float distance=0; CH_SR04_Init(); printf("Senor_Using\n"); }

STM32F103CB使用MAX485接收不到

PC向主机串口1发送的数据,由串口2经MAX485转发,从机接收数据并通过MAX485到串口2,最后控制继电器。目前发现串口1发送485发送的数据正常,从机用示波器测量MAX485和串口2处有信号,但是从机芯片无法接收。主机从机发送正常,单独使用串口2发送到串口1也正常。 串口2是PA2和PA3,使用PA4做MAX485控制引脚 #define RS485_TX GPIO_SetBits(GPIOA,GPIO_Pin_4) //485发送使能(在使用时注意有响应延时) #define RS485_RX GPIO_ResetBits(GPIOA,GPIO_Pin_4) //485接收使能(在使用时注意有响应延时) #define USART2_RX_EN 1 //0:不接收;1:接收 #define USART_REC_LEN 200 //定义最大接收字节数 200 u16 USART_RX_STA; // 串口1接收状态标志 u8 USART_RX_BUF[USART_REC_LEN]; //串口1接收缓冲 /** //功能:RS485串口2初始化 //参数:bound:波特率 //返回值:None **/ void RS485_Init(u32 bound) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); /*************************************GPIO Config****************************************/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA,&GPIO_InitStructure); #if USART2_RX_EN /*************************************USART Config*****************************************/ USART_InitStructure.USART_BaudRate = bound; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2,&USART_InitStructure); USART_Cmd(USART1, ENABLE); //使能串口外设 USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //使能串口接收中断 USART_ClearFlag(USART1, USART_FLAG_TC); //软件清除发送完成标志位 /**************************************NVIC Config*****************************************/ NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority =2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif RS485_RX; //485默认接收 } //********************串口2中断服务函数**********// void USART2_IRQHandler() { u16 temp; if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) //接收中断,必须以0x0d,0x0a结尾 { temp = USART_ReceiveData(USART2); //读取接收到的数据 if((USART_RX_STA & 0x8000) == 0) //接收未完成 { if(USART_RX_STA & 0x4000) //如果接收到了0x0d { if(temp != 0x0a) USART_RX_STA = 0; //接受错误,重新开始接收 else { USART_RX_STA |= 0x8000; //接收完成 } } else //未收到0x0d { if(temp == 0x0d) USART_RX_STA |= 0X4000; else { USART_RX_BUF[USART_RX_STA & 0X3FFF] = temp; USART_RX_STA++; if(USART_RX_STA > (USART_REC_LEN - 1)) USART_RX_STA = 0; //接收数据错误,重新开始接收 } } } }else if(USART_GetFlagStatus(USART2,USART_FLAG_IDLE)!=RESET) { USART_ClearFlag(USART2,USART_FLAG_IDLE); } } int main() { u16 t = 0; u8 length; u16 times=0; SysTick_Init(); Delay_us(100); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC优先级分组2:2位抢占优先级,2位响应优先级 UART1_Init(115200); UART2_Init(9600); RS485_Init(9600); printf("\r\n01 finsh\r\n"); printf("\r\n等待接收\r\n"); while(1) { if(USART_RX_STA & 0x8000) { RS485_RX; Delay_ms(100); length = USART_RX_STA&0X3fff; //获取数据长 printf("\r\nyour massage is:\r\n"); for(t=0;t<length;t++) { Delay_us(1000); SendByte(USART1,USART_RX_BUF[t]);//自己写的发送函数,正常 } printf("\r\n发送完成\r\n"); RS485_RX; USART_RX_STA=0; }else { times++; if(times % 5000 == 0) { printf("\r\nlab\r\n"); printf("ALIENTEK\r\n\r\n"); } if(times % 200 == 0) printf("\r\n waitting \r\n"); if(times % 30 == 0) printf("\r\nsystem runing\n");//提示系统正在运行 Delay_ms(10); } } }

STM32串口接收数据有时候会出错

void USART_Config(void) { GPIO_InitTypeDef GPIO_InitStruct ; USART_InitTypeDef USART_InitStruct ; NVIC_InitTypeDef NVIC_InitStruct ; #ifdef DMA_EN DMA_InitTypeDef DMA_InitStructure ; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //DMA1通道5配置 DMA_DeInit(DMA1_Channel6); //USART2_RX DMA1 channel 6 //外设地址 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&USART2->DR); //内存地址 DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART_Rev_Buffer; //dma传输方向单向 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //设置DMA在传输时缓冲区的长度 DMA_InitStructure.DMA_BufferSize = 40 ;//UART_RX_LEN; //设置DMA的外设递增模式,一个外设 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //设置DMA的内存递增模式 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //外设数据字长 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //内存数据字长 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //设置DMA的传输模式 DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //设置DMA的优先级别 DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; //设置DMA的2个memory中的变量互相访问 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel6,&DMA_InitStructure); //使能通道6 DMA_Cmd(DMA1_Channel6,ENABLE); #endif RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); USART_DeInit(USART2) ; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2 ; //USART1-TX GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz ; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP ; GPIO_Init(GPIOA,&GPIO_InitStruct); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 ; //USART1-RX GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz ; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING ; GPIO_Init(GPIOA,&GPIO_InitStruct); USART_InitStruct.USART_BaudRate = 115200 ; USART_InitStruct.USART_WordLength = USART_WordLength_8b ; USART_InitStruct.USART_StopBits = USART_StopBits_1 ; USART_InitStruct.USART_Parity = USART_Parity_No ; USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx ; USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None ; USART_Init(USART2,&USART_InitStruct) ; NVIC_InitStruct.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0 ; //抢占优先级 3 NVIC_InitStruct.NVIC_IRQChannelSubPriority = 3; //子优先级 3 NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; //IRQ 通道使能 NVIC_Init(&NVIC_InitStruct); USART_ITConfig(USART2,USART_IT_IDLE,ENABLE) ; /* CPU的小缺陷:串口配置好,如果直接Send,则第1个字节发送不出去 如下语句解决第1个字节无法正确发送出去的问题 */ //USART_ClearFlag(USART2, USART_FLAG_TC); /* 清发送外城标志,Transmission Complete*/ USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE); // 开启串口DMA接收 USART_Cmd(USART2, ENABLE); } void USART2_IRQHandler(void) { uint8_t temp = 0; uint8_t i = 0; if(USART_GetITStatus(USART2, USART_IT_IDLE) != RESET) { //USART_ClearFlag(USART1,USART_IT_IDLE); temp = USART2->SR; temp = USART2->DR; //清USART_IT_IDLE标志 DMA_Cmd(DMA1_Channel6,DISABLE); temp = 40 - DMA_GetCurrDataCounter(DMA1_Channel6); //接收到数据的长度 for(i=0;i<temp;i++) { printf(" %x ",USART_Rev_Buffer[i]); } printf("\r\n"); printf("\r\n"); //if(temp == USART_Rev_Buffer[4]+5) //{ // USART_FLAG_RX = 1 ; //标志位置1 //USART_TX = 0 ; //} //设置传输数据长度 DMA_SetCurrDataCounter(DMA1_Channel6,40); //打开DMA DMA_Cmd(DMA1_Channel6,ENABLE); } __nop(); } ![图片说明](https://img-ask.csdn.net/upload/201704/13/1492079684_720557.png)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

删库了,我们一定要跑路吗?

在工作中,我们误删数据或者数据库,我们一定需要跑路吗?我看未必,程序员一定要学会自救,神不知鬼不觉的将数据找回。 在 mysql 数据库中,我们知道 binlog 日志记录了我们对数据库的所有操作,所以 binlog 日志就是我们自救的利器。 接下来就来开启程序员自救之路。 想要自救成功,binlog 这把利器一定要好,在自己之前,我们一定要确定我们有 binlog 这把利器,以下就是确保有 bi...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

现代的 “Hello, World”,可不仅仅是几行代码而已

作者 |Charles R. Martin译者 | 弯月,责编 | 夕颜头图 |付费下载自视觉中国出品 | CSDN(ID:CSDNnews)新手...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐