ST意法半导体
直播中

李耀鑫

7年用户 210经验值
私信 关注
[问答]

我需要使用uart2接收带中断的数据吗?

您好我是端口uart2轮询接收来自超级终端的数据没关系。但我需要使用uart2接收带中断的数据?


tiM3_DeInit();

TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);
TIM3_ITConfig(TIM3_IT_UPDATE,ENABLE);
enableInterrupts();
GPIO_Init(GPIOD,0x01,GPIO_MODE_OUT_PP_LOW_FAST);

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

UART2_DeInit();
UART2_Init((u32)9600,UART2_WORDLENGTH_8D,UART2_STOPBITS_1,UART2_PARITY_NO,UART2_SYNCMODE_CLOCK_DISABLE,UART2_MODE_TXRX_ENABLE);

UART2_ClearITPendingBit(UART2_IT_RXNE);
UART2_ITConfig(UART2_IT_IDLE,ENABLE);


这段代码不正确我不知道使用功能,看看注册请帮帮我

以上来自于谷歌翻译


以下为原文




Hello i'm port uart2 polling receive data from hyperterminal it's ok. but i need use uart2 receive data with interrupt?


   TIM3_DeInit();
   
   TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);
    TIM3_ITConfig(TIM3_IT_UPDATE, ENABLE);
     enableInterrupts();
     GPIO_Init(GPIOD, 0x01 , GPIO_MODE_OUT_PP_LOW_FAST);
         
     CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

     UART2_DeInit();
     UART2_Init((u32)9600, UART2_WORDLENGTH_8D,    UART2_STOPBITS_1, UART2_PARITY_NO, UART2_SYNCMODE_CLOCK_DISABLE, UART2_MODE_TXRX_ENABLE);

     UART2_ClearITPendingBit(UART2_IT_RXNE);
     UART2_ITConfig(UART2_IT_IDLE, ENABLE);


this code incorrect i don't know use function and see a register please help me

回帖(3)

欧丽娜

2019-7-16 10:19:08
TIM3_DeInit();
 
TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);
TIM3_ITConfig(TIM3_IT_UPDATE,ENABLE);
enableInterrupts();
GPIO_Init(GPIOD,0x01,GPIO_MODE_OUT_PP_LOW_FAST);
 
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
 
UART2_DeInit();
UART2_Init((u32)9600,UART2_WORDLENGTH_8D,UART2_STOPBITS_1,UART2_PARITY_NO,UART2_SYNCMODE_CLOCK_DISABLE,UART2_MODE_TXRX_ENABLE);
 
UART2_ClearITPendingBit(UART2_IT_RXNE);
UART2_ITConfig(UART2_IT_IDLE,ENABLE);
 
 
UART2_ITConfig(UART2_IT_RXNE_OR,ENABLE);

以上来自于谷歌翻译


以下为原文









TIM3_DeInit();

TIM3_TimeBaseInit(TIM3_PRESCALER_1,0xFFFF);
TIM3_ITConfig(TIM3_IT_UPDATE, ENABLE);
enableInterrupts();
GPIO_Init(GPIOD, 0x01 , GPIO_MODE_OUT_PP_LOW_FAST);

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

UART2_DeInit();
UART2_Init((u32)9600, UART2_WORDLENGTH_8D,    UART2_STOPBITS_1, UART2_PARITY_NO, UART2_SYNCMODE_CLOCK_DISABLE, UART2_MODE_TXRX_ENABLE);

UART2_ClearITPendingBit(UART2_IT_RXNE);
UART2_ITConfig(UART2_IT_IDLE, ENABLE);




UART2_ITConfig(UART2_IT_RXNE_OR, ENABLE);
举报

廖阿朋

2019-7-16 10:25:45
在从UART2中断例程读取一个字节后,我是否需要使用UART2_ClearITPendingBit()函数,或者自己的读取操作清除了挂起的位RXNE,我有疑问。我无法从RM0016参考手册中找到此信息。
 
我正在使用的代码:
 
#ifdef _COSMIC_
@far @interrupt void UART2_RX_IRQHandler(void)
#else / * _RAISONANCE_ * /
void UART2_RX_IRQHandler(void)中断21
#endif / * _COSMIC_ * /
{
 //从接收数据寄存器中读取一个字节
 RxBuffer [RxCounter ++] = UART2_ReceiveData8();
 
 
 如果(
RxCounter == 128)
 
 RxCounter = 0;
 。
 。
 。
}

以上来自于谷歌翻译


以下为原文









I´m in doubt if I need to use the UART2_ClearITPendingBit() function after read a byte from UART2 Interruption routine, or the own read action clears the pending bit RXNE. I couldn´t find this information from RM0016 reference manual.


The code I´m using:


#ifdef _COSMIC_
@far @interrupt void UART2_RX_IRQHandler(void)
#else /* _RAISONANCE_ */
void UART2_RX_IRQHandler(void) interrupt 21
#endif /* _COSMIC_ */
{
  // Read one byte from the receive data register
  RxBuffer[RxCounter++] = UART2_ReceiveData8();
  


  

  if(
RxCounter==128)

     
   RxCounter=0;

  .

  .

  .
}
举报

廖阿朋

2019-7-16 10:45:18
我已经在这里测试过,这个功能没有必要。

以上来自于谷歌翻译


以下为原文





I´ve already tested here,  that function is not necessary.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分