Group05_Lab06_Task1/Lab6_Task1.c

60 lines
961 B
C

#include <stdint.h>
#include <stdbool.h>
#include "tm4c123gh6pm.h"
#define mask_bits 0x11 //mask bits for user switch
void GPIOF_config(void);
void GPIOF_Int_Config(void);
void main(void)
{
SYSCTL_RCC_R &= ~(1 << 20); //SYSTEM CLOCK SOURCE FOR 16MHz PWM
SYSCTL_RCGC0_R |= 0x00100000; //enable clock for PWM module
SYSCTL_RCGCPWM_R = 0x3; //
GPIOF_config();
GPIOF_Interrupt_config();
GPIO_PORTF_AFSEL_R |= 0x02;
GPIO_PORTF_PCTL_R |= 0x50;
PWM1_2_CTL_R= 0x00000000;
PWM1_2_GENB_R |= 0x80E;
PWM1_2_LOAD_R = 0xA0;
PWM1_2_CMPB_R = 0x50;
PWM1_2_CTL_R |=0x01;
PWM1_ENABLE_R |=(1<<5);
while(1);
}
void GPIOF_config()
{
SYSCTL_RCGC2_R |= 0x20;
GPIO_PORTF_LOCK_R = 0x4C4F434B;
GPIO_PORTF_CR_R = 0x1F;
GPIO_PORTF_DEN_R= 0x1F;
GPIO_PORTF_DIR_R= 0x0E;
GPIO_PORTF_PUR_R = 0x11;
}