Part Number: TM4C1294NCPDT
Tool/software: Starterware
Dear sir,
we are using our designed Board and using the basic GPIO code but we are finding different behaviour on Reset of the same line.
1 We are using 1S delay then we are getting LED blinking exactly after 1S .
2 When we apply reset then it is changing the Blinking time to 400 ms as seen from CRO.
We are new to this controller and i am posting my code which i have used from the Example of CCS.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "drivers/pinout.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/ssi.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "drivers/buttons.h"
#define NUM_SSI_DATA 3 // Number of bytes to send and receive.
uint32_t g_ui32SysClock; // System clock rate in Hz.
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void delayMS(int ms) {
SysCtlDelay( (SysCtlClockGet()/(3*1000))*ms ) ;
}
void
InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); // Enable GPIO port A which is used for UART0 pins.
GPIOPinConfigure(GPIO_PJ0_U3RX); // Configure the UART0 pin A0.
GPIOPinConfigure(GPIO_PJ1_U3TX); // Configure the UART0 pin A1.
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); // Enable UART0 so that we can configure the clock.
UARTClockSourceSet(UART3_BASE, UART_CLOCK_PIOSC); // Use the internal 16MHz oscillator as the UART clock source.
GPIOPinTypeUART(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Configure the GPIO Port a pins
UARTStdioConfig(0, 115200, 16000000); // Initialize the UART for console I/O.
}
int
main(void)
{
volatile uint32_t ui32Loop;
uint32_t pui32DataTx[NUM_SSI_DATA];
uint32_t pui32DataRx[NUM_SSI_DATA];
uint32_t ui32Index;
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | // Run from the PLL at 120 MHz.
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOQ));
GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_1|GPIO_PIN_0);
PinoutSet(false, false); // Configure the device pins.
InitConsole(); // Set up the serial console to use for displaying messages.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // Enable the GPIO port that is used for the on-board LED.
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); // The SSI0 peripheral must be enabled for use.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // GPIO port A needs to be enabled so SSI pins can be used.
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); // Enable the GPIO pin for the LED (PN0).
GPIOPinConfigure(GPIO_PF3_SSI3CLK); // Configure the SSI SCLK on PA2
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // ~CS - configure it as GPIO output
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_1); // ~CS - set it to logic HIGH
GPIOPinConfigure(GPIO_PF1_SSI3XDAT0); // Configure the MOSI on PA4
GPIOPinConfigure(GPIO_PF0_SSI3XDAT1); // Configure the MISO on PA5
GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0| GPIO_PIN_1 | GPIO_PIN_3); // Configure the GPIO settings for the SSI pins.
SSIConfigSetExpClk(SSI3_BASE, g_ui32SysClock, SSI_FRF_MOTO_MODE_0, // Configure and enable the SSI port for SPI master mode. Use SSI3,
SSI_MODE_MASTER, 1000000, 8); // system clock supply, idle clock level low and active low clock in
// Freescale SPI mode, master mode, 1 MHz SSI frequency, and 8-bit data.
SSIEnable(SSI3_BASE); // Enable the SSI0 module.
//
// Initialize the data to send.
//
pui32DataTx[0] = 0x30; // read mode
pui32DataTx[1] = 0x5A; // register address to read
pui32DataTx[2] = 0x55; // dummy byte to generate SCLK for reading 1 byte from MISO
//
// Send 3 bytes of data.
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); // ~CS - set it to logic LOW - start of transmission
SysCtlDelay(1);
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
SSIDataPut(SSI3_BASE, pui32DataTx[ui32Index]);
SSIDataPut(SSI3_BASE, pui32DataRx[ui32Index]);
}
SysCtlDelay(1);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2,0x1); // ~CS - set it to logic HIGH - end of transmission*/
while(1)
{
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PIN_1);
delayMS(10000) ; // 15ms delay
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, 0x0);
delayMS(10000) ; // 15ms delay
UARTprintf("Checking TX and RX data...\n"); // check the contents of pui32DataRx
UARTprintf("i\tTX\tRX\n");
UARTprintf("--------------------------\n");
for(ui32Index = 0 ; ui32Index < NUM_SSI_DATA ; ui32Index++)
{
UARTprintf("%d\t'%c'\t'%c'\n", ui32Index,
*(pui32DataTx+ui32Index),
*(pui32DataRx+ui32Index));
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_0, GPIO_PIN_0);
}
}
}
Kindly suggest something for the issue,as because of this we are not able to work on other protocols also.
NOTE :Power to the controller is fine and it is 3.3V.
Regards,
Sateesh