cancel
Showing results for 
Search instead for 
Did you mean: 

USART3_IRQHandler is not invoked.

psati
Associate II

char recv_string[10];

char data;

int count = -1,i,data_check = -1;

void USART3_IRQHandler(void) //my interrupt handler

{

if(USART_GetITStatus(USART3,USART_IT_TXE))

{

data = USART_GetChar();

if(data == 0x0D || data == 0x08)

data_check = 1;

else 

data_check = 0;

}

USART_ClearITPendingBit(USART3,USART_IT_TXE);

}

void usart3_fun()

{

//structure initialise

USART_InitTypeDef my_usart_init;

GPIO_InitTypeDef my_gpio_init;

NVIC_InitTypeDef my_nvic_init;

//Enable clock

  

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

//GPIO Configurations

my_gpio_init.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;

my_gpio_init.GPIO_Mode = GPIO_Mode_AF;

my_gpio_init.GPIO_OType = GPIO_OType_PP;

my_gpio_init.GPIO_PuPd = GPIO_PuPd_UP;

my_gpio_init.GPIO_Speed = GPIO_Speed_100MHz;

//USART Base Initialisation

my_usart_init.USART_BaudRate = 9600;

my_usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

my_usart_init.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

my_usart_init.USART_Parity = USART_Parity_No;

my_usart_init.USART_StopBits = USART_StopBits_1;

my_usart_init.USART_WordLength = USART_WordLength_8b;

//Enable Rx interrupt

USART_ITConfig(USART3,USART_IT_RXNE, ENABLE);

//NVIC Initialization

my_nvic_init.NVIC_IRQChannel = USART3_IRQn;

my_nvic_init.NVIC_IRQChannelCmd = ENABLE;

my_nvic_init.NVIC_IRQChannelPreemptionPriority = 0;

my_nvic_init.NVIC_IRQChannelSubPriority = 0;

//Init functions

GPIO_Init(GPIOB, &my_gpio_init);

USART_Init(USART3, &my_usart_init);

NVIC_Init(&my_nvic_init);

//Alternate Function

GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3);

GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);

//ENABLE Peripheral

USART_Cmd(USART3, ENABLE);

}

//void comman

void data_get()

{

usart3_fun(); //initializing USART3

while(1)

{

if(data_check == 1)

{

USART3_send_char('\n');

USART3_send_char('\r');

if(data == 0x08){

//Backspace

print_string();

for(i=0;i<=count;i++)

recv_string[i] = NULL; //executing this statement first in while(1)

count = -1; //executing this statement second in while(1)

}

else{

//checking command

//data_process(recv_string);

print_string(); //calls send character function in it.

for(i=0;i<=count;i++)

recv_string[i] = NULL;

count = -1;

}

USART3_send_char('\n');

USART3_send_char('\r');

data_check = -1;

}

else if (data_check == -1) //executing this statement third in while(1)

{

data_check = -1; //nothing waiting for input data

}

else

{

count++;

USART3_send_char(data); //STM32 send character function

recv_string[count] = data;

data_check = -1;

}

}

}

main()

{

 /* SysTick end of count event each 10ms */

 RCC_GetClocksFreq(&RCC_Clocks);

 SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

data_get();//function in main

}

1 ACCEPTED SOLUTION

Accepted Solutions

The TXE interrupt is NOT for getting data from the USART, you enable RXNE interrupt and look for TXE.

It will only interrupt if it actually receives data.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

The TXE interrupt is NOT for getting data from the USART, you enable RXNE interrupt and look for TXE.

It will only interrupt if it actually receives data.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you so much👍

😀 .