PIC16F877-L298-Motor-Configuration

by Marwen Maghrebi
#include <xc.h>
#include <stdint.h>

// Configuration Bits
#pragma config FOSC = XT        // XT Oscillator
#pragma config WDTE = OFF       // Watchdog Timer Disabled
#pragma config PWRTE = OFF      // Power-up Timer Disabled
#pragma config BOREN = ON       // Brown-out Reset Enabled
#pragma config LVP = OFF        // Low-Voltage Programming Disabled
#pragma config CPD = OFF        // Data EEPROM Code Protection Disabled
#pragma config WRT = OFF        // Flash Program Write Protection Disabled
#pragma config CP = OFF         // Flash Program Code Protection Disabled

#define _XTAL_FREQ 16000000  // 16 MHz crystal frequency

// Motor Control Pins
#define ENA RC2   // PWM for Motor A
#define IN1 RD0   // Direction for Motor A
#define IN2 RD1   // Direction for Motor A
#define ENB RC1   // PWM for Motor B
#define IN3 RD2   // Direction for Motor B
#define IN4 RD3   // Direction for Motor B

// Direction Definitions
#define FORWARD 1
#define BACKWARD 2

// Function Prototypes
void setupPWM();
void setPWMDutyCycle(int speedA, int speedB);
void runMotorA(int direction, int speed);
void runMotorB(int direction, int speed);
void stopMotors();
void delay_ms(unsigned int ms);
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00