I need Serial Port Driver for Philips LPC17xx????????????????????????? For ppp Connection with null modem cable
#include <LPC17xx.H> #include "..\main.h" #include "uart_driver.h" #include "..\gpio\gpio_driver.h" void UART_Init(UARTNo_Type Uartno, uint16_t Baudrate) { uint32_t least_val; LPC_SC->PCLKSEL0 &= ~(3<<6 | 3<<8); switch (Uartno) { case UART0: LPC_PINCON->PINSEL0 |= (1<<4) | (1<<6); LPC_UART0->THR = 0; LPC_UART0->LCR = 1<<7; least_val = (uint16_t) (12000000/(16*Baudrate*1.5f)); LPC_UART0->FDR = (2<<4) | (1<<0); LPC_UART0->DLL = (uint8_t)least_val; LPC_UART0->DLM = (uint8_t)least_val >> 8; LPC_UART0->LCR = 0; LPC_UART0->FCR = 0x07; LPC_UART0->LCR = 0x03; LPC_UART0->TER = (1 << 7); LPC_UART0->IER = UART_IERBR | UART_IETHRE; NVIC_EnableIRQ(UART0_IRQn); Rx0BufCntr = 0; gUART0_BusyFlg = UART_IDLE; break; case UART1: break; case 2: LPC_SC->PCONP |= PCUART2; break; case 3: break; } } /*---- END OF UART_Init() ----*/ void UART_TxByte(UARTNo_Type Uartno, uint8_t Data) { volatile uint8_t temp; switch (Uartno) { case UART0: do { temp = LPC_UART0->LSR; temp &= 0x60; } while(temp != 0x60); LPC_UART0->THR = Data & READ_1BYTE; break; } } /*---- END OF UART_TxByte() ----*/ void UART0_IRQHandler(void) { uint8_t interrupt_status, line_status, rxdata; static uint8_t crflg=0; uint8_t dummy=dummy; //dummy is never used. hence it generates warnings. This line is written to remove the warnings. interrupt_status = 0x07 & (LPC_UART0->IIR >> 1); if(interrupt_status == UART_RDA) { rxdata = LPC_UART0->RBR; switch(rxdata) { case SOF: //Don't store Start of Frame Character if(gUART0_BusyFlg == UART_IDLE) { Rx0BufCntr = 0; gUART0_BusyFlg = UART_BUSY; //gRx0_CompleteFlg = RX_BUSY; gUART0_IntFlg=0; } break; case CR: crflg = 1; //Indicates 10 received gRx0Buf[Rx0BufCntr++] = CR; break; case LF: if(crflg) //Check for a valid CR received. For Command no 10 & 13, this needs to be checked. { --Rx0BufCntr; gRx0LRC = gRx0Buf[--Rx0BufCntr]; gRx0Buf[Rx0BufCntr++] = NUL; gRx0Buf[Rx0BufCntr] = NUL; gUART0_IntFlg = 1; gUART0_BusyFlg = UART_IDLE; UART0_DisableRx(); isr_evt_set (TASK_RX,TID_TxRxDisplayData); Rx0BufCntr = 0; } else { gRx0Buf[Rx0BufCntr++] = rxdata; } break; default: crflg = 0; gRx0Buf[Rx0BufCntr++] = rxdata; break; } } if(interrupt_status == UART_THRE) { line_status = LPC_UART0->LSR; if(gTx0Buf[Tx0BufCntr] != NUL) { LPC_UART0->THR = gTx0Buf[Tx0BufCntr++]; } else { Tx0BufCntr = 0; gUART0_BusyFlg = UART_IDLE; UART0_EnableRx(); //enable reception } } } /*---- END OF UART0_IRQHandler() ----*/ /*~~~~ END OF FUNCTIONS ~~~~*/
The code is as it is. Works fine for me, but No warranty. PS: it may even damage your circuit.
You need code. Hire a consultant.
it may even damage your circuit
I just tried it and my board burst into flames!
Fortunately I always carry a fire extinguisher for such emergencies.