- Create New Folder on Documents (or any location) and name it
- On Microvision ==> Project ==> New Microvision Project & name it ==> ARM Cortex M4 ==> ARMCM4
- Copy/paste "inc" folder that includes "tm4c123gh6pm.h" on new folder you created on step 1.
- Copy/paste "startup.s on new folder your created on step 1.
- On Microvision, right-click on Source Group 1
- Add existing ==> startup.s
- Add new item to group ==> c file ==> name it "main (or any that you'd like)"
- Make sure to click on "options for target" ==> debug ==> "Use:" ==> "Stellaris ICDI"
Sunday, April 21, 2019
Keil/Microvision - Creating a New Project for Tiva™ C Series TM4C123G LaunchPad
Stepper Motor Code
/*
7 files needed for this code to work:
Header Files
1. stepper.h // don't add to source group
2. systick.h // don't add to source group
Source (group) Code Files (you only add .c type files, not .h which is called on the #include)
3. startup.s // add to source group
4. stepper.c // add to source group
5. main.c (in this case, mainStep.c) // add to source group
6. SysTick.c // add to source group
*/
#include "inc/tm4c123gh6pm.h"
#include <stdint.h>
#include "stepper.h"
#define T1ms 16000 // assumes using 16 MHz PIOSC (default setting // for clock source)
int main(void){
Stepper_Init();
Stepper_CCW(T1ms); // Pos=1; GPIO_PORTD_DATA_R=9
Stepper_CCW(T1ms); // Pos=2; GPIO_PORTD_DATA_R=5
Stepper_CCW(T1ms); // Pos=3; GPIO_PORTD_DATA_R=6
Stepper_CCW(T1ms); // Pos=4; GPIO_PORTD_DATA_R=10
Stepper_CCW(T1ms); // Pos=5; GPIO_PORTD_DATA_R=9
Stepper_CCW(T1ms); // Pos=6; GPIO_PORTD_DATA_R=5
Stepper_CCW(T1ms); // Pos=7; GPIO_PORTD_DATA_R=6
Stepper_CCW(T1ms); // Pos=8; GPIO_PORTD_DATA_R=10
SYSCTL_RCGC2_R |= 0x18; // Using PORT E
GPIO_PORTE_AMSEL_R &=~ 0x01;// 3) disable analog functionality on PD3-0
GPIO_PORTE_DIR_R &=~ 0x01;// 5) make PD3-0 out
GPIO_PORTE_AFSEL_R &=~ 0x01;// 6) disable alt functon PD3-0
GPIO_PORTE_DEN_R |= 0x01;// 7) enable digital I/O on PD3-0
while(1){
if ((GPIO_PORTE_DATA_R &0x01) == 0x00) {
Stepper_CW(2*T1ms); // output every 10ms
}
else {
Stepper_CCW(2*T1ms); // output every 10ms
//Stepper_Seek(50, 2*T1ms);
}
}
}
7 files needed for this code to work:
Header Files
1. stepper.h // don't add to source group
2. systick.h // don't add to source group
Source (group) Code Files (you only add .c type files, not .h which is called on the #include)
3. startup.s // add to source group
4. stepper.c // add to source group
5. main.c (in this case, mainStep.c) // add to source group
6. SysTick.c // add to source group
*/
#include "inc/tm4c123gh6pm.h"
#include <stdint.h>
#include "stepper.h"
#define T1ms 16000 // assumes using 16 MHz PIOSC (default setting // for clock source)
int main(void){
Stepper_Init();
Stepper_CCW(T1ms); // Pos=1; GPIO_PORTD_DATA_R=9
Stepper_CCW(T1ms); // Pos=2; GPIO_PORTD_DATA_R=5
Stepper_CCW(T1ms); // Pos=3; GPIO_PORTD_DATA_R=6
Stepper_CCW(T1ms); // Pos=4; GPIO_PORTD_DATA_R=10
Stepper_CCW(T1ms); // Pos=5; GPIO_PORTD_DATA_R=9
Stepper_CCW(T1ms); // Pos=6; GPIO_PORTD_DATA_R=5
Stepper_CCW(T1ms); // Pos=7; GPIO_PORTD_DATA_R=6
Stepper_CCW(T1ms); // Pos=8; GPIO_PORTD_DATA_R=10
SYSCTL_RCGC2_R |= 0x18; // Using PORT E
GPIO_PORTE_AMSEL_R &=~ 0x01;// 3) disable analog functionality on PD3-0
GPIO_PORTE_DIR_R &=~ 0x01;// 5) make PD3-0 out
GPIO_PORTE_AFSEL_R &=~ 0x01;// 6) disable alt functon PD3-0
GPIO_PORTE_DEN_R |= 0x01;// 7) enable digital I/O on PD3-0
while(1){
if ((GPIO_PORTE_DATA_R &0x01) == 0x00) {
Stepper_CW(2*T1ms); // output every 10ms
}
else {
Stepper_CCW(2*T1ms); // output every 10ms
//Stepper_Seek(50, 2*T1ms);
}
}
}
Subscribe to:
Posts (Atom)