I am using LM4F232H5QD evaluation board. I got demo code of UART in which it using this function :-
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
to set clock source.
Now I want to merge this code with a demo code for ADC in which clock source is define as his:-
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
Now, problem is as there should be only one clock source in the program but If I use first function then my ADC is not compatible with and If I ue secind options then my usrt runs but with an unknown baudrate. So, I want to know how can set clock source which is compatable for both things.
Here is my code for UART:-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(void)
{
tRectangle sRect;
tContext sContext;
//
// Set the clocking to run at 50 MHz from the PLL.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
//
// Fill the top part of the screen with blue to create the banner.
//
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.sYMax = 9;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Change foreground for white text.
//
GrContextForegroundSet(&sContext, ClrWhite);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, g_pFontFixed6x8);
GrStringDrawCentered(&sContext, "softuart-echo", -1,
GrContextDpyWidthGet(&sContext) / 2, 4, 0);
//
// Initialize the display and write some instructions.
//
GrStringDrawCentered(&sContext, "Connect a", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, false);
GrStringDrawCentered(&sContext, "terminal", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, false);
GrStringDrawCentered(&sContext, "to UART0.", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, false);
GrStringDrawCentered(&sContext, "115000,N,8,1", -1,
GrContextDpyWidthGet(&sContext) / 2, 50, false);
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//
// Compute the bit time for 115,200 baud.
//
g_ulBitTime = (ROM_SysCtlClockGet() / 115200) - 1;
//
// Configure the SoftUART for 8-N-1 operation.
//
SoftUARTInit(&g_sUART);
SoftUARTRxGPIOSet(&g_sUART, GPIO_PORTA_BASE, GPIO_PIN_0);
SoftUARTTxGPIOSet(&g_sUART, GPIO_PORTA_BASE, GPIO_PIN_1);
SoftUARTRxBufferSet(&g_sUART, g_pusRxBuffer,
sizeof(g_pusRxBuffer) / sizeof(g_pusRxBuffer[0]));
SoftUARTTxBufferSet(&g_sUART, g_pucTxBuffer, sizeof(g_pucTxBuffer));
SoftUARTCallbackSet(&g_sUART, SoftUARTIntHandler);
SoftUARTConfigSet(&g_sUART,
(SOFTUART_CONFIG_WLEN_8 | SOFTUART_CONFIG_STOP_ONE |
SOFTUART_CONFIG_PAR_NONE));
//
// Configure the timer for the SoftUART transmitter.
//
ROM_TimerConfigure(TIMER0_BASE,
(TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC |
TIMER_CFG_B_PERIODIC));
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ulBitTime);
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT | TIMER_TIMB_TIMEOUT);
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
//
// Set the priorities of the interrupts associated with the SoftUART. The
// receiver is higher priority than the transmitter, and the receiver edge
// interrupt is higher priority than the receiver timer interrupt.
//
ROM_IntPrioritySet(INT_GPIOA, 0x00);
ROM_IntPrioritySet(INT_TIMER0B, 0x40);
ROM_IntPrioritySet(INT_TIMER0A, 0x80);
//
// Enable the interrupts associated with the SoftUART.
//
ROM_IntEnable(INT_TIMER0A);
ROM_IntEnable(INT_TIMER0B);
ROM_IntEnable(INT_GPIOA);
//
// Prompt for text to be entered.
//
UARTSend((unsigned char *)"\033[2JEnter text: ", 16);
//
// Enable the SoftUART interrupt.
//
SoftUARTIntEnable(&g_sUART, SOFTUART_INT_RX | SOFTUART_INT_RT);
//
// Loop forever echoing data through the UART.
//
while(1)
{
//
// Wait until there are characters available in the receive buffer.
//
while(g_ulFlag == 0)
{
}
g_ulFlag = 0;
//
// Loop while there are characters in the receive buffer.
//
while(SoftUARTCharsAvail(&g_sUART))
{
//
// Read the next character from the UART and write it back to the
// UART.
//
SoftUARTCharPutNonBlocking(&g_sUART,
SoftUARTCharGetNonBlocking(&g_sUART));
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
And here is my code for ADC:-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(void)
{
unsigned long ulADC0_Value[3];
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH8);
ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH9);
ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH21 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 0);
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 0);
while(!ADCIntStatus(ADC0_BASE, 0, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 0, ulADC0_Value);
SysCtlDelay(SysCtlClockGet() / 12);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////