Hidayah
Newbie level 2
define delay of dsk5416
Hi there,
Below is my program to use gpio of dsk5416 as output pin to a stepper motor. But this program have error. I use Code Composer Studio v3.1 software to run this program. Can you help me to correct or provide me the correct the coding ? Thanks.
-------------------------------------------------------------------------------------------
#include <dsk5416.h>
#include <csl_gpio.h>
#define GPIO_PIN0 ((Uint16)(0x0001))
#define GPIO_PIN1 ((Uint16)(0x0002))
#define GPIO_PIN2 ((Uint16)(0x0004))
#define GPIO_PIN3 ((Uint16)(0x0008))
#define GPIO_OUTPUT0 ((Uint16)(0x0001))
#define GPIO_OUTPUT1 ((Uint16)(0x0002))
#define GPIO_OUTPUT2 ((Uint16)(0x0004))
#define GPIO_OUTPUT3 ((Uint16)(0x0008))
#define DELAY 0xfffff
void delay(void)
{
long i, j=0;
for(i=0;i<DELAY;i++){
j++;
}
}
void main()
{
GPIO_pinEnable(GPIO_PIN0);
GPIO_pinEnable(GPIO_PIN1);
GPIO_pinEnable(GPIO_PIN2);
GPIO_pinEnable(GPIO_PIN3);
GPIO_pinDirection(GPIO_PIN0,GPIO_OUTPUT0);
GPIO_pinDirection(GPIO_PIN1,GPIO_OUTPUT1);
GPIO_pinDirection(GPIO_PIN2,GPIO_OUTPUT2);
GPIO_pinDirection(GPIO_PIN3,GPIO_OUTPUT3);
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,1);
delay();
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,1);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,1);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
GPIO_pinWrite(GPIO_PIN0,1);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
}
------------------------------------------------------------------------------------------
Regards,
Dayah[/code]
Hi there,
Below is my program to use gpio of dsk5416 as output pin to a stepper motor. But this program have error. I use Code Composer Studio v3.1 software to run this program. Can you help me to correct or provide me the correct the coding ? Thanks.
-------------------------------------------------------------------------------------------
#include <dsk5416.h>
#include <csl_gpio.h>
#define GPIO_PIN0 ((Uint16)(0x0001))
#define GPIO_PIN1 ((Uint16)(0x0002))
#define GPIO_PIN2 ((Uint16)(0x0004))
#define GPIO_PIN3 ((Uint16)(0x0008))
#define GPIO_OUTPUT0 ((Uint16)(0x0001))
#define GPIO_OUTPUT1 ((Uint16)(0x0002))
#define GPIO_OUTPUT2 ((Uint16)(0x0004))
#define GPIO_OUTPUT3 ((Uint16)(0x0008))
#define DELAY 0xfffff
void delay(void)
{
long i, j=0;
for(i=0;i<DELAY;i++){
j++;
}
}
void main()
{
GPIO_pinEnable(GPIO_PIN0);
GPIO_pinEnable(GPIO_PIN1);
GPIO_pinEnable(GPIO_PIN2);
GPIO_pinEnable(GPIO_PIN3);
GPIO_pinDirection(GPIO_PIN0,GPIO_OUTPUT0);
GPIO_pinDirection(GPIO_PIN1,GPIO_OUTPUT1);
GPIO_pinDirection(GPIO_PIN2,GPIO_OUTPUT2);
GPIO_pinDirection(GPIO_PIN3,GPIO_OUTPUT3);
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,1);
delay();
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,1);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
GPIO_pinWrite(GPIO_PIN0,0);
GPIO_pinWrite(GPIO_PIN1,1);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
GPIO_pinWrite(GPIO_PIN0,1);
GPIO_pinWrite(GPIO_PIN1,0);
GPIO_pinWrite(GPIO_PIN2,0);
GPIO_pinWrite(GPIO_PIN3,0);
delay();
}
------------------------------------------------------------------------------------------
Regards,
Dayah[/code]