Tool/software: Code Composer Studio
I tried to use systick to create a delay.But only first led is always on ...
my code is below..
#include <stdint.h>
#include "tm4c123gh6pm.h"
void SysTick_Init(void); // initialize SysTick Timer
void SysTick_Wait(unsigned long delay1);
void SysTick_Wait10ms(unsigned long delay1); // waiting time
// ***** 2. Global Declarations Section *****
// FUNCTION PROTOTYPES: Each subroutine defined
//Next[8] array represents 8 inputs and the next state transition
//The first array element represents 000 input, the second represents 001 input and so on upto 111 (eighth input)
//Input bits representation- MSB=Walk Sensor,Middle bit=South Sensor and LSB=West Sensor
//FSM[9]={
//{ouput to Six signal LEDs (TrafficLights_Cars),output to two Pedestrian LEDs (TrafficLights_Ped),Time in 10ms units,Next[8] array elements(next states)},
// ..............
unsigned long Input;
// ***** 3. Subroutines Section *****
int main(void) {
volatile unsigned long delay;
GPIO_PORTB_AMSEL_R=0x00; //disable analog on port B
GPIO_PORTE_AMSEL_R=0x00; //disable analog on port E
GPIO_PORTB_PCTL_R=0x00000000; //enable regular GPIO
GPIO_PORTE_PCTL_R=0x00000000; //enable regular GPIO
GPIO_PORTB_DIR_R=0x1F; //outputs on PB0-5
GPIO_PORTE_DIR_R=0x00; //inputs on PE0-2
GPIO_PORTB_AFSEL_R=0x00; //disable alternate function
GPIO_PORTE_AFSEL_R=0x00; //disable alternate function
GPIO_PORTB_DEN_R=0x1F; //enable digital I/O on PB0-5
GPIO_PORTE_DEN_R=0x07; //enable digital I/O on PE0-2
while(1){
GPIO_PORTB_DATA_R=0x01;
SysTick_Wait10ms(100);
GPIO_PORTB_DATA_R=0x02;
SysTick_Wait10ms(100);
}
}
void SysTick_Init(void){
NVIC_ST_CTRL_R = 0; // disable SysTick during setup
NVIC_ST_CTRL_R = 0x00000005; // enable SysTick with core clock
}
// The delay parameter is in units of the 80 MHz core clock. (12.5 ns)
void SysTick_Wait(unsigned long delay2){
NVIC_ST_RELOAD_R = delay2-1; // number of counts to wait
NVIC_ST_CURRENT_R = 0; // any value written to CURRENT clears
while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for count flag
}
}
// 800000*12.5ns equals 10ms
void SysTick_Wait10ms(unsigned long delay1){
unsigned long i;
for(i=0; i<delay1; i++){
SysTick_Wait(800000); // wait 10ms
}
}