Hi
Is anyone able to help me. I am new to the LPC1857.
I am using the MCB1857 development board and i want to use USART3.
I can send characters after configuration using the below:-
LPC_USART3->THR = 'K';
I am unable to get the interrupt to trigger at all. My code is:-
/*protoctype*/
__irq void UART3_IRQHandler (void);
/*****************************************************************************/
/**************** SET UP USART 3 *************************************/
LPC_SCU->SFSP2_3 = 0x02;
LPC_SCU->SFSP2_4 = 0x02;
LPC_USART3->LCR = 0x83; /*line control register.. stop, data bits etc.... 8 data bits, 1stop bit, NO parity*/
LPC_USART3->FDR = 0; /*fractional divide*/
LPC_USART3->DLL = 78; /*divide latch LSB... 9600 buad*/
LPC_USART3->DLM = 0; /*divide latch MSB*/
LPC_USART3->LCR = 0x03; /* disab;e DLAB*/
LPC_USART3->FCR = 0x07; /*Fifo buffer*/
LPC_USART3->IER = 0x01; /*enable interupt*/
NVIC_SetPriority(USART3_IRQn, 1);
NVIC_EnableIRQ(USART3_IRQn); /*enable USART3 interupt*/
/********************************************************************************/
/* ####### USART interupt function ########################## */
/********************************************************************************/
__irq void UART3_IRQHandler(void)
{
unsigned short ushLocalVar = 0;
/*recieving a byte*/
if(LPC_USART3->LSR & 0x01)
{
ushLocalVar = LPC_USART3->RBR;
}
if((ushLocalVar == 'A') || (ushLocalVar == 'a'))
{
/*transmit a byte*/
if(LPC_USART3->LSR & 0x20)
{
LPC_USART3->THR = 'K';
}
}
else
{
LPC_USART3->IER = 0x01; /*re-enable interupt*/
}
}
解決済! 解決策の投稿を見る。
Hi Andrew,
You are welcome.
After you try it, if you still have question, just let me know!
If your question is solved, please help to mark the correct answer to close the question.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Andrew Barningham,
About the LPC1857 UART3 interrupt code, you can refer to our LPCopen code for the MCB1857 board.
1. LPCXpresso IDE project
http://www.nxp.com/assets/downloads/data/en/software/lpcopen_2_20_lpcxpresso_keil_mcb_1857.zip
Folder:lpcopen_2_12_lpcxpresso_keil_mcb_1857\periph_uart
2, IAR and MDK project
http://www.nxp.com/assets/downloads/data/en/software/lpcopen_2_20_keil_iar_keil_mcb_1857.zip
Folder:lpcopen_2_12_keil_iar_keil_mcb_1857\applications\lpc18xx_43xx\iar_ewarm_projects\keil_mcb_1857\periph\periph_uart
App_Interrupt_Test() function is the UART3 interrupt configuration and test function.
You can run the periph_uart code in your MCB1857 board directly. The UART port is UART0/UART3. J16 ,J13 should connect pin2-3.
Please test the official uart project at first.
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kerry,
That's great thanks for your help.
I seem to be missing the chip.h and board.h header files and unable to find them.
Is it possible you can advise me where to find them.
Thanks in advance.
Andrew
Hi Andrew Barningham,
You can find the chip.h in the lpc_chip_18xx lib, board.h in lpc_board_keil_mcb_1857 lib.
Take the lpcopen lpcxpresso project as an example:
When you add the project, you must add the lpc_board_keil_mcb_1857 and lpc_chip_18xx at first, then add your own project or other application project.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kerry,
I will try that.... thank you very much for your help.
Andrew
Hi Andrew,
You are welcome.
After you try it, if you still have question, just let me know!
If your question is solved, please help to mark the correct answer to close the question.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------