Hi,
I have those;
LPC1769
FreeRTOS 10.3.2
UART1
And except UART1 init issue, the rest (uIP, Led flashing test, etc…) is working OK.
I believe that the problem must be obvious to some expert on FreeRTOS.
The issue is, at some point within UART1 initialization, application stops. If I read my debugger correctly, it falls in hard-fault (HFSR > Forced = 1).
Here is the method where UART1 initializes;
I call the init method in this order within main method;
prvSetupHardware();
uart1_init(38600);
void uart1_init(uint32_t __baudrate)
{
uint32_t Fdiv;
uint32_t pclkdiv, pclk;
PINCON->PINSEL4 &= ~0x0000000F;
PINCON->PINSEL4 |= 0x0000000A; /* Enable RxD1 P2.1, TxD1 P2.0 */
/* By default, the PCLKSELx value is zero, thus, the PCLK for
all the peripherals is 1/4 of the SystemFrequency. */
/* Bit 8,9 are for UART1 */
pclkdiv = (SC->PCLKSEL0 >> 8) & 0x03;
switch ( pclkdiv )
{
case 0x00:
default:
pclk = ( unsigned long ) 4000000UL / 4;
break;
case 0x01:
pclk = ( unsigned long ) 4000000UL;
break;
case 0x02:
pclk = ( unsigned long ) 4000000UL / 2;
break;
case 0x03:
pclk = ( unsigned long ) 4000000UL / 8;
break;
}
UART1->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
Fdiv = ( pclk / 16 ) / __baudrate ; /*baud rate */
UART1->DLM = Fdiv / 256;
UART1->DLL = Fdiv % 256;
UART1->LCR = 0x03; /* DLAB = 0 */
UART1->FCR = 0x07; /* Enable and reset TX and RX FIFO. */
Using debugger I found out, it doesn’t go further than this line; UART1->DLM = Fdiv / 256;
You may find my FreeRTOSConfig.h
attached in case of you may need to see some settings.
You may also ask some further code from the application.
EDIT:
I also add here hardware setup funtion.
void prvSetupHardware( void )
{
/* Disable peripherals power. */
SC->PCONP = 0;
/* Enable GPIO power. */
SC->PCONP = PCONP_PCGPIO;
/* Disable TPIU. */
PINCON->PINSEL10 = 0;
if ( SC->PLL0STAT & ( 1 << 25 ) )
{
/* Enable PLL, disconnected. */
SC->PLL0CON = 1;
SC->PLL0FEED = PLLFEED_FEED1;
SC->PLL0FEED = PLLFEED_FEED2;
}
/* Disable PLL, disconnected. */
SC->PLL0CON = 0;
SC->PLL0FEED = PLLFEED_FEED1;
SC->PLL0FEED = PLLFEED_FEED2;
SC->SCS = (1<<5); //enable main oscillator bit 5
while ((SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready */
/* Enable main OSC. ORIGINAL */
// SC->SCS |= 0x20;
// while( !( SC->SCS & 0x40 ) );
/* select main OSC, 12MHz, as the PLL clock source. */
SC->CLKSRCSEL = 0x1;
SC->PLL0CFG = 0x00050077; //0x20031;
SC->PLL0FEED = PLLFEED_FEED1;
SC->PLL0FEED = PLLFEED_FEED2;
/* Enable PLL, disconnected. */
SC->PLL0CON = 1;
SC->PLL0FEED = PLLFEED_FEED1;
SC->PLL0FEED = PLLFEED_FEED2;
/* Set clock divider. */
SC->CCLKCFG = 0x03;
/* Configure flash accelerator. */
SC->FLASHCFG = 0x403a;
/* Check lock bit status. */
while( ( ( SC->PLL0STAT & ( 1 << 26 ) ) == 0 ) );
/* Enable and connect. */
SC->PLL0CON = 3;
SC->PLL0FEED = PLLFEED_FEED1;
SC->PLL0FEED = PLLFEED_FEED2;
while( ( ( SC->PLL0STAT & ( 1 << 25 ) ) == 0 ) );
/* Configure the clock for the USB. */
if( SC->PLL1STAT & ( 1 << 9 ) )
{
/* Enable PLL, disconnected. */
SC->PLL1CON = 1;
SC->PLL1FEED = PLLFEED_FEED1;
SC->PLL1FEED = PLLFEED_FEED2;
}
/* Disable PLL, disconnected. */
SC->PLL1CON = 0;
SC->PLL1FEED = PLLFEED_FEED1;
SC->PLL1FEED = PLLFEED_FEED2;
SC->PLL1CFG = 0x23;
SC->PLL1FEED = PLLFEED_FEED1;
SC->PLL1FEED = PLLFEED_FEED2;
/* Enable PLL, disconnected. */
SC->PLL1CON = 1;
SC->PLL1FEED = PLLFEED_FEED1;
SC->PLL1FEED = PLLFEED_FEED2;
while( ( ( SC->PLL1STAT & ( 1 << 10 ) ) == 0 ) );
/* Enable and connect. */
SC->PLL1CON = 3;
SC->PLL1FEED = PLLFEED_FEED1;
SC->PLL1FEED = PLLFEED_FEED2;
while( ( ( SC->PLL1STAT & ( 1 << 9 ) ) == 0 ) );
/* Setup the peripheral bus to be the same as the CPU output (100 MHz). */
SC->PCLKSEL0 = 0x05555555;
/* Configure the LEDs. */
vParTestInitialise();
//Piezoelectric Buzzer
GPIO2->FIODIR |= (0x1<<4); /* P2.4 defined as Outputs */
GPIO2->FIOCLR = (0x1<<4); /* Set it LOW so it won't make noise at the begining */
}
I appreciate your inputs from now.
Best Regards,
Sener
FreeRTOSConfig.h (6.5 KB)