#include <stdint.h>
#include "inc/tm4c123gh6pm.h"
#define COMMAND (*((volatile unsigned long *)(0x42000000 +(0x43FC)*32 +0x06*4)))
#define RESET (*((volatile unsigned long *)(0x42000000 +(0x43FC)*32 +0x07*4)))
#define RED_LED (*((volatile uint32_t *)(0x42000000 + (0x400253FC-0x40000000)*32 + 1*4)))
#define GREEN_LED (*((volatile uint32_t *)(0x42000000 + (0x400253FC-0x40000000)*32 + 3*4)))
#define PUSH_BUTTON (*((volatile uint32_t *)(0x42000000 + (0x400253FC-0x40000000)*32 + 4*4)))
void delay()
{ unsigned long i,j,h;
int m=0;
for(i=0;i<999;i++)
{
for( j=0;j<9999;j++)
for( h=0;h<9999;h++)
m++;
}
}
void check_Break_Point()
{ int k;
//RESET=1;
for( k=0;k<5;k++)
{
RESET=1;
delay();
delay();
delay();
RESET=0;
delay();
delay();
delay();
}
}
void Port_A_Init()
{
SYSCTL_RCC_R = SYSCTL_RCC_XTAL_16MHZ | SYSCTL_RCC_OSCSRC_MAIN | SYSCTL_RCC_USESYSDIV | (4 << SYSCTL_RCC_SYSDIV_S);
unsigned long dummy;
dummy=SYSCTL_RCC_R;
SYSCTL_RCGC2_R = 0x00000001;
dummy= SYSCTL_RCGC2_R;
//GPIO_PORTA_LOCK_R = 0x4C4F434B;
GPIO_PORTA_CR_R = 0x1F;
GPIO_PORTA_AMSEL_R = 0x00;
GPIO_PORTA_PCTL_R = 0x00222200;
GPIO_PORTA_DIR_R = 0x0FC;
GPIO_PORTA_AFSEL_R = 0x3C;
GPIO_PORTA_PUR_R = 0x00;
GPIO_PORTA_DEN_R = 0xFF;
}
void Port_F_Init()
{
// Configure HW to work with 16 MHz XTAL, PLL enabled, system clock of 40 MHz
//SYSCTL_RCC_R = SYSCTL_RCC_XTAL_16MHZ | SYSCTL_RCC_OSCSRC_MAIN | SYSCTL_RCC_USESYSDIV | (4 << SYSCTL_RCC_SYSDIV_S);
// Set GPIO ports to use APB (not needed since default configuration -- for clarity)
SYSCTL_GPIOHBCTL_R = 0;
// Enable GPIO port F peripherals
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
// Configure LED and pushbutton pins
GPIO_PORTF_DIR_R = 0x0F; // bits 1 and 3 are outputs, other pins are inputs
GPIO_PORTF_DR2R_R = 0x0F; // set drive strength to 2mA (not needed since default configuration -- for clarity)
GPIO_PORTF_DEN_R = 0x1F;// enable LEDs and pushbuttons
GPIO_PORTF_PUR_R = 0x10; // enable internal pull-up for push button
}
void serial_Interface_Init()
{
SYSCTL_RCGCSSI_R=0x01;
SYSCTL_RCGC1_R |= SYSCTL_RCGC1_SSI0;
SSI0_CR1_R=0x00000000;
SSI0_CR0_R=0x000004C7;
SSI0_CPSR_R=0x00000002;
SSI0_CC_R=0x00;
}
void serial_Interface_Enable()
{
SSI0_CR1_R=0x02;
}
void serial_Interface_Disable()
{
SSI0_CR1_R=0x00;
}
void serial_Datapass(int command, int data)
{
COMMAND=command;
SSI0_DR_R=data;
}
void serial_Command()
{
serial_Interface_Init();
//check_Break_Point();
serial_Interface_Enable();
serial_Datapass(0,0x21);
serial_Datapass(0,0xB1);
serial_Datapass(0,0x04);
serial_Datapass(0,0x14);
serial_Datapass(0,0x20);
serial_Datapass(0,0x0C);
serial_Datapass(0,0x0C);
//RESET=1;
}
int main()
{
Port_F_Init();
while(1)
{
RED_LED=1;
delay();
RED_LED=0;
delay();
GREEN_LED=1;
delay();
GREEN_LED=0;
delay();
}
//while(SSI_SR_TNF==1);
//serial_Datapass(1,0x1F);
//serial_Datapass(1,0x1F);
return 0;
}
hi i can debug the EK123 and i need to clear the flash everytime i need to program o else its popping up the error