Created
December 27, 2016 12:36
-
-
Save elktros/12930cea4d7b60b2d411f888026e4534 to your computer and use it in GitHub Desktop.
DC Motor Control Using ARM7 (LPC2148)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<lpc214x.h> | |
#define MOTOR (1<<18) | (1<<19) | |
#define BUTTON (1<<16) | |
int main() | |
{ | |
unsigned char i=0; | |
PINSEL0 = 0x00000000; | |
PINSEL1 = 0x00000000; | |
PINSEL2 = 0x00000000; | |
IODIR1 = MOTOR; | |
IODIR0 = IODIR0 & (~BUTTON); | |
PLL0CON = 0x01; | |
PLL0CFG = 0x24; | |
PLL0FEED = 0xAA; | |
PLL0FEED = 0x55; | |
while(!(PLL0STAT & 0x00000400)); | |
PLL0CON = 0x03; | |
PLL0FEED = 0xAA; | |
PLL0FEED = 0x55; | |
VPBDIV = 0x01; | |
while(1) | |
{ | |
while((IOPIN0 & BUTTON)==0); | |
i=~i; | |
if(i==0xFF) | |
{ | |
IOSET1 = (1<<18); | |
IOCLR1 = (1<<19); | |
} | |
else | |
{ | |
IOSET1 = (1<<19); | |
IOCLR1 = (1<<18); | |
} | |
while((IOPIN0 & BUTTON)==0x00010000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment