Hi Guys
How I can to delay the operation of my program?
I tried using DELAY_US (1000000), but it not worked.
I wish that when I play in the program, he began to run after a set time.
Best regards
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi Guys
How I can to delay the operation of my program?
I tried using DELAY_US (1000000), but it not worked.
I wish that when I play in the program, he began to run after a set time.
Best regards
Hi Gautam.
Don't worked with the function DELAY.
I take off the function, and left only loop "for for
(i=_IQ(0); i<_IQ(3000000); i++)
but i don't understand the time calculation.
For i<3000000, the time give 8.31 seconds. On 28027, for 1 seconds, would be 60e^6 clock cycle?
Best Regards
Patrick, using only for loop will give you some random delay. So tuning them becomes very hard. Instead DELAY_US delay should work for you. Are you getting any error while using DELAY_US? Also, I would like to know in which part of the code are you implementing this delay?
Regards,
Gautam
Gautam, the program not show me any error. I put the code before the void (man) void.
I tried put the code in other places but don't worked.
CLK_Handle myClk;
FLASH_Handle myFlash;
GPIO_Handle myGpio;
PIE_Handle myPie;
SCI_Handle mySci;
//TIMER_Handle myTimer0;
PWM_Handle myPwm4;
//unsigned long timer0IntCount;
void delay1s(void)
{
for(i=0; i<10; i++)
{
DELAY_US (1000000);
}
}
void main(void)
{
CPU_Handle myCpu;
PLL_Handle myPll;
WDOG_Handle myWDog;
// Initialize all the handles needed for this application
myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
mySci = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));
myPwm4 = PWM_init((void *)PWM_ePWM4_BASE_ADDR, sizeof(PWM_Obj));
// myTimer0 = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
And later i do this way:
void main(void)
{
for(i=_IQ1(0); i<_IQ1(2000000); i++)
{
}
CPU_Handle myCpu;
PLL_Handle myPll;
WDOG_Handle myWDog;
// Initialize all the handles needed for this application
myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
mySci = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));
myPwm4 = PWM_init((void *)PWM_ePWM4_BASE_ADDR, sizeof(PWM_Obj));
// myTimer0 = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
this last example, worked e saved in flash memory . But when i turn off the piccolo (usb port turn off) and later turn on, the program not run alone.
For resolving this you can refer "flash_f28027" in controlSuite.
Also, in your previous implementation where did you call delay1s function?
Regards,
Gautam
I did call inside void main (void). I tried call in many places of void man, but don't work.
best regards.
Which controller are you using? I'll forward Delay_us.asm file to you then.
Regards,
Gautam
I am using the F28027 Piccolo.
Will be that file F2802x_usDelay.asm that i have is with error?
regards
My code is wrong?
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "f2802x_common/include/adc.h"
#include "f2802x_common/include/clk.h"
#include "f2802x_common/include/flash.h"
#include "f2802x_common/include/gpio.h"
#include "f2802x_common/include/pie.h"
#include "f2802x_common/include/pll.h"
#include "f2802x_common/include/sci.h"
#include "f2802x_common/include/pwm.h"
#include "f2802x_common/include/timer.h"
#include "f2802x_common/include/wdog.h"
Uint16 i;
void delays5s(void)
{
for(i=0; i<10; i++)
{
DELAY_US (500000);
}
}
void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void scia_msg(char *msg);
#define MATH_TYPE IQ_MATH
#define GLOBAL_Q 24
#include "IQmathLib.h"
// Prototype statements for functions found within this file.
interrupt void adc_isr1(void);
void Adc_Config(void);
// Global variables used in this example:
Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Count;
uint16_t ReceivedChar;
int16 Tensao_A[8];
int16 Amostra_A=0;
int16 Amostra_a=0;
int error;
long Posicao_A;
_iq Vref_A; // Tensão de Referencia, sinal a ser sincronizado.
_iq Verr_A; // Tensão de erro. Entrada do Filtro.
_iq kprop_A; // Saída do Proporcional.
_iq kint_A; // Amostra Anterior do Integral do PI e sáida do I.
_iq kp; // Constante Proporcional do PI.
_iq ki; // Constante de Integração do PI.
_iq Sat_lim_max; // Saturador do PI.
_iq Sat_lim_min; // Saturador do PI.
_iq V_A;
_iq Vrms_A; // Valor RMS da Tensão Medida.
_iq Vcontrole_A; // Sinal de saída do Pi.
char *msg;
char buffer[30];
_iq Y;
_iq X;
_iq Z;
ADC_Handle myAdc;
CLK_Handle myClk;
FLASH_Handle myFlash;
GPIO_Handle myGpio;
PIE_Handle myPie;
SCI_Handle mySci;
TIMER_Handle myTimer0;
PWM_Handle myPwm4;
unsigned long timer0IntCount;
void main(void)
{
delays5s();
CPU_Handle myCpu;
PLL_Handle myPll;
WDOG_Handle myWDog;
// Initialize all the handles needed for this application
myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
mySci = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));
myPwm4 = PWM_init((void *)PWM_ePWM4_BASE_ADDR, sizeof(PWM_Obj));
myTimer0 = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
timer0IntCount=0;
//continue...
Try attaching this file and also don't forget to remove the previous one from the project.
Regards,
Gautam
Don't worked with file 3835.F2802x_usDelay.asm
When i put de code of delays, and call delays() function inside main, before the inicializations, the debug is done, but when i play nothing happen.
Whein i put de code of delays, inside man and inside loop series comunication, or before inicialization ADC, the debug is done, but when i play show the error DefautIsr.
regards.
Hi Partick,
I would like you try the same delay routine in one of the example codes available in controlSuite.
Do let me know what you observe. This might give us an idea on whether this is project based issue or compiler based issue.
Regards,
Gautam
Hi.
I don't found in controlsuit example with delay.
In web i found one example that blink leds using DELAY_US(XXXX) to temporize, but don't work when i put DELAY_US(XXXXX) in a code with interruption, series comunication, etc.
Maybe is missing enable for delay, somethink like that or any file to add that enable delay, i don't now.
Regards.
Patrick, use gpio toggle example in controlSuite and add this delay there. You don't have to add any special file to the project.
Regards,
Gautam