In a short initialization function for setting up USART1 interrupt capability, when this command is called it hangs the code.
Code: Select all
NVIC_IntEnable(IVT_INT_USART1);
I have no explanation why. Perhaps mE can enlighten me.
Code: Select all
NVIC_IntEnable(IVT_INT_USART1);
Code: Select all
#include "TFT_objects.h"
#include "TFT_resources.h"
sbit UART_Int_LED at GPIOD_ODR.B8;
sbit UART_msgFlag_LED at GPIOD_ODR.B9;
void displayUART_Text (void);
void UART1_RX_Init (void);
unsigned char RX_msgArray [32] = {0x00};
unsigned char inBuffer = 0;
unsigned char RX_ByteCount = 0;
unsigned char RX_msgFlag = 0;
//==================================================================================================================
//==================================================================================================================
void main()
{
GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_ALL); // Set PORTD as output
UART_Int_LED = 0;
UART_msgFlag_LED = 0;
UART1_Init(115200);
UART1_Write_Text("UART RX Int Test\r\n");
Start_TP();
TFT_Fill_Screen(CL_NAVY);
TFT_Set_Font(&Comic_Sans_MS_Regular_24x28, CL_SILVER, FO_HORIZONTAL);
TFT_Write_Text("UART RX Int TEST", 10, 60);
delay_ms (1000);
TFT_Fill_Screen(CL_NAVY);
UART1_RX_Init();
displayUART_Text();
while (1);
}//!
/********************************************************************************************************
* Name: INT_UART1_RX
* Description: ISR for receiving one byte from the UART
* Arguments: none
* Returns: none
********************************************************************************************************/
void INT_UART1_RX() iv IVT_INT_USART1 ics ICS_AUTO
{
if (USART1_SRbits.RXNE)
{
USART1_SRbits.RXNE = 0; // clear interrupt intflag
inBuffer = USART1_DR; // read receive buffer
if (inBuffer == 0x0D)
{
RX_msgArray[RX_ByteCount] = inBuffer;
inBuffer = 0x00;
RX_ByteCount++;
RX_msgArray[RX_ByteCount] = 0x00; // add null termination to string array
RX_msgFlag = 1; // set flag indicating a complete message has been received
GPIOD_ODR = RX_ByteCount; // <<< TEST - LED indicator for # received bytes >>>
UART1_Write_Text(&RX_msgArray[0]); // echo received text string. << TEST >>
}
else
{
RX_msgArray[RX_ByteCount] = inBuffer;
RX_ByteCount++;
inBuffer = 0x00;
RX_msgFlag = 0x00;
}
}
}//!
/*******************************************************************************
* Name: UART1_RX_Init
* Description: Function sets up UART1 for interrupt driven RX
* Arguments: Nothing
* Returns: Nothing
*******************************************************************************/
void UART1_RX_Init (void)
{
UART1_Init(115200);
USART1_CR1.RXNEIE = 1; // enable USART1 RX interrupt
NVIC_IntEnable(IVT_INT_USART1);
EnableInterrupts();
}//!
/********************************************************************************************************
* Name: displayUART_Text
* Description: display received USART text
* Arguments: none
* Returns: none
********************************************************************************************************/
void displayUART_Text (void)
{
RX_msgFlag = 0;
RX_ByteCount = 0;
UART_Int_LED = 1; // indicate this function has been entered << test LED >>
while (1)
{
while (!RX_msgFlag); // loop here waiting for a \r terminated message string to arrive
//=====
TFT_Write_Text(&RX_msgArray[0], 10, 60); // display received string for a few seconds
delay_ms (3000);
TFT_Fill_Screen(CL_NAVY); // clear the screen
RX_msgFlag = 0; // reset flag and counter
RX_ByteCount = 0;
//=====
}
}//!
Ok, which situations are they and why? The compiler documentation does not say anything about this, how does mE expect it's users to fully utilize the interrupt capability unless it's documented? Do you expect us to be mind readers?it's not mandatory to use EnableInterrupts() routine in every situation.
This answer is taken directly from the help file and is very confusing. Please explain in more detail what exactly does this mean.This does not affect the set of interrupts enabled in the interrupt controller - it just gates the single interrupt from the controller
to the processor.