Documente Academic
Documente Profesional
Documente Cultură
Module
PWM4Wheel.c
Revision
1.0
Description
This is the PWM4Wheel Module for Initialization of PWM for wheels, set the
direction and duty cycle of PWM.
Notes
History
When
Who
What/Why
----------------------02/10/2015
10:33 Sky
Initial version
****************************************************************************/
#include <stdint.h>
#include
#include
#include
#include
#include
#include
#include
"inc/hw_memmap.h"
"inc/hw_gpio.h"
"inc/hw_pwm.h"
"inc/hw_sysctl.h"
"inc/hw_types.h"
"bitdefs.h"
<stdio.h>
#include "PWM4Wheel.h"
// 40,000 ticks per mS assumes a 40Mhz clock, we will use SysClk/32 for PWM
#define PWMTicksPerMS 8000/32
// set 200 Hz frequency so 5mS period
#define PeriodInMS 1
#define BitsPerNibble 4
#define FORWARD 0
#define BACKWARD 1
#define LEFTWHEEL 1
#define RIGHTWHEEL 2
#ifndef ALL_BITS
#define ALL_BITS (0xff<<2)
#endif
static uint8_t DirectionLeft;
static uint8_t DirectionRight;
// we will use PWM module 0 for this demo and program it for up/down counting
void InitPWMDemo( void ){
volatile uint32_t Dummy; // use volatile to avoid over-optimization
// start by enabling the clock to the PWM Module (PWM0)
HWREG(SYSCTL_RCGCPWM) |= SYSCTL_RCGCPWM_R0;
// enable the clock to Port B
HWREG(SYSCTL_RCGCGPIO) |= SYSCTL_RCGCGPIO_R1;
: No return
: This function will set new dutycycle to PWM channel(channelNum
ARGUMENTS
BACKWARD)
RETURN
: No return
DESCRIPTION
HEEL)