Sir ,using the below program i am trying to flicker led .For generating pseudorandom numbers i am using lfsr technique.To check if i am getting the random number or not i am displaying it on the serial monitor using uart.The output which i am getting on the serial monitor is garbage value,along with that ,no flickering of led is hapenning.
/* Defines the base address of the memories and peripherals */
#include "inc/hw_memmap.h"
/* Defines the common types and macros */
#include "inc/hw_types.h"
/* Defines and Macros for GPIO API */
#include "driverlib/gpio.h"
/* Prototypes for the system control driver */
#include "driverlib/sysctl.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "utils/uartstdio.h"
unsigned int red,grn,op,lfsr=0x1F61; //declaring the hex value for lfsr
unsigned int bit;
void InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* Make the UART pins be peripheral controlled. */
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
/* Initialize the UART for console I/O */
UARTStdioInit(0);
}
int main(void)
{
/*Set the clocking to directly run from the crystal at 16MHz*/
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_20MHZ);
/* Set the clock for the GPIO Port F */
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
/* Set the type of the GPIO Pin */
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
/* GPIO Pin 1 on PORT F initialized to 0 */
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0);
InitConsole();
while(1)
{
bit=((lfsr>>0)^(lfsr>>1)^(lfsr>>3)^(lfsr>>5))&1; // right shift operation
lfsr=(lfsr>>1)|(bit<<15); //changing the value of lfsr
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,bit); //switching on and off led
SysCtlDelay(SysCtlClockGet()/3); //delay
UARTprintf("\nrandom no"); //printing the random number on serial monitor
UARTprintf("%d",lfsr);
}
}