I am working on the TI-RSLK kit and I am stuck in the module 9 lab. that lab is about lighting an LED using a PWM signal. Now I have written the code for that, but LED is not glowing. Can someone help me and point out the mistake that I have made?
#include <stdint.h>
#include <stdio.h>
#include "msp.h"
#include "..\inc\TExaS.h"
#include "..\inc\Clock.h"
#include "..\inc\CortexM.h"
#include "..\inc\SysTick.h"
#include "..\inc\LaunchPad.h"
uint8_t d, data, data1,data2;
/*void SysTick_Init(void){ This is initialized through the SysTick.h file
SysTick->LOAD = 0x00FFFFFF;
SysTick->CTRL = 0x00000005;
}
void SysTick_Wait(uint32_t delay){
if(delay <= 1){
return;
}
SysTick->LOAD = delay-1;
SysTick->VAL = 0;
while((SysTick->CTRL&0x00010000) == 0){};
}*/
void SysTick_Wait1us(uint32_t delay){
uint32_t i;
for(i=0; i<delay; i++){
SysTick_Wait(48);
}
}
int Program9_1(void){
Clock_Init48MHz(); // makes bus clock 48 MHz
SysTick_Init();
LaunchPad_Init(); // buttons and LEDs
TExaS_Init(LOGICANALYZER_P1);
while(1){
if(data2==0x00){
P1->OUT = 0x00;
return 0;
}
else{
P1->OUT |= 0x01; // red LED on
SysTick_Wait1us(7500);
P1->OUT &= ~0x01; // red LED off
SysTick_Wait1us(2500);
}
}
}
// Operation
// The heartbeat starts when the operator pushes Button 1
// The heartbeat stops when the operator pushes Button 2
// When beating, the P1.0 LED oscillates at 100 Hz (too fast to see with the eye)
// and the duty cycle is varied sinuosoidally once a second
int main(void){
Clock_Init48MHz(); // makes it 48 MHz
TExaS_Init(LOGICANALYZER_P1);
LaunchPad_Init(); // buttons and LEDs
SysTick_Init();
// write this code
EnableInterrupts();
while(1){
P1->OUT = 0x00;
data = P1->IN;
data1 = data&0x02;
data2 = data&0x08;
if(data1 == 0x00){
d=Program9_1();
}
}
}
Thanks in advance