Hi,
i want to write a code for a PWM.
Config.netX.c:
{"EATIMER",RX_PERIPHERAL_TYPE_TIMER,0}, // EinAus Timer
1, // use counter 1
1000000, // 1000000µs = 1second
FALSE, // Continuous Mode, trigger again and again
FALSE, // Interrupt disabled
FALSE, // No external Clock
RX_HWTIMER_TRIGGER_NONE, // No Trigger
0, // No I/O reference
0 // No Prescaler
},
............
{{"GPIOOUT",RX_PERIPHERAL_TYPE_GPIO,0},
14, // GPIO 14
RX_GPIO_TYPE_OUTPUT, // GPIO as Output
RX_GPIO_POLARITY_NORMAL, // high active
RX_GPIO_OUTPUTMODE_PWM, // PWM Mode
RX_GPIO_COUNTER_1, // Reference Counter is Counter1
FALSE, // Disables IRQ
1000, // Threshold: 1000µs = 1ms
}//Indifizierung des EA_Timers
if((eRslt = Drv_TimIdentifyTimer("EATIMER",0,&ptRscE->tRem.phTim))!=TLR_S_OK)
{
goto leave;
}
//Indifizierung des GPIO
if((eRslt = Drv_GpioIdentifyGpio("GPIOOUT",0,&ptRscE->tRem.phGpio))!=TLR_S_OK)
{
goto leave;
}
//Initialisierung des EA_Timers
if((eRslt = Drv_TimInitializeTimer(ptRscE->tRem.phTim))!=TLR_S_OK)
{
goto leave;
}
//Initialisierung des GPIOs
if((eRslt = Drv_GpioInitializeGpio(ptRscE->tRem.phGpio))!=TLR_S_OK)
{
goto leave;
}
eRslt = Drv_TimStartTimer(ptRscE->tRem.phTim);
eRslt = rX_TimGetTime(ptRscE->tRem.phTim, &TimVal);
eRslt = rX_TimGetTime(ptRscE->tRem.phTim, &TimVal);
eRslt = rX_TimGetTime(ptRscE->tRem.phTim, &TimVal);
eRslt = rX_TimGetTime(ptRscE->tRem.phTim, &TimVal);
eRslt = rX_TimGetTime(ptRscE->tRem.phTim, &TimVal);
regards
Hi, thanks for the Help.
i have now an other problem. i want to use a GPIO as a Switch. He should turn on or off after a certain time.
this is my code :
....
if((EoA != EoA_1)&&(EoA == 1))
{
//********************Ein****************************************************
eRslt = Drv_TimStopTimer(ptRscE->tRem.phTim1);
eRslt = Drv_TimGetTime(ptRscE->tRem.phTim1, &TimVal);
POKE(NETX_GPIO_THRSH_CAPT14,(Gpio14Max*100));
//GPIO Standard: ptGpio14Cfg->mode = 1 --- GPIO low: ptGpio14Cfg->inv = 1
Gpio14Mode = (PEEK(ptGpio14Cfg)&0xFFFFFFEF) | 0xC;
POKE(ptGpio14Cfg, Gpio14Mode);
//start Count1
eRslt = Drv_TimStartTimer(ptRscE->tRem.phTim1);
//GPIO14 PWM
ptGpio14Cfg->mode = 3;
//***************************************************************************
}
else if((EoA != EoA_1)&& (EoA == 0))
{
//********************Aus****************************************************
eRslt = Drv_TimStopTimer(ptRscE->tRem.phTim1);
eRslt = Drv_TimGetTime(ptRscE->tRem.phTim1, &TimVal);
POKE(NETX_GPIO_THRSH_CAPT14,(Gpio14Max*100));
//GPIO Standard: ptGpio14Cfg->mode = 1 --- GPIO low: ptGpio14Cfg->inv = 0
Gpio14Mode = (PEEK(ptGpio14Cfg)& 0xFFFFFFEB) | 0x8;
POKE(ptGpio14Cfg, Gpio14Mode);
//start Count1
eRslt = Drv_TimStartTimer(ptRscE->tRem.phTim1);
//GPIO PWM
ptGpio14Cfg->mode = 3;
//***************************************************************************
}Regards
Hilscher Gesellschaft für Systemautomation mbH
I am not able to understand your problem, or what you are trying to do.
But from the code I see, i have some remarks. Why you are trying to reconfigure the GPIO to output mode temporarily?
Wouldn't it be easier to keep it in PWM mode and just restart the timer? Another thing. Why don't you first set it to PWM mode and start the timer afterwards.
Informational:
-------------
The PWM module always sets the output to "high level" for the 0 <= time
Regards
MT
Hi,
i have to program a "programable limit switch". It works like a PWM.
If i should switch off (the switch is at the moment on, and after "Gpio14Max" µsec it should be off) then:
eRslt = Drv_TimStopTimer(ptRscE->tRem.phTim1);
POKE(NETX_GPIO_THRSH_CAPT14,(Gpio14Max*100));
//GPIO Standard: ptGpio14Cfg->mode = 1 --- GPIO low: ptGpio14Cfg->inv = 0
Gpio14Mode = (PEEK(ptGpio14Cfg)& 0xFFFFFFEB) | 0x8;
POKE(ptGpio14Cfg, Gpio14Mode);
//start Count1
eRslt = Drv_TimStartTimer(ptRscE->tRem.phTim1);
//GPIO PWM
ptGpio14Cfg->mode = 3;
eRslt = Drv_TimStopTimer(ptRscE->tRem.phTim1);
POKE(NETX_GPIO_THRSH_CAPT14,(Gpio14Max*100));
//GPIO Standard: ptGpio14Cfg->mode = 1 --- GPIO low: ptGpio14Cfg->inv = 1
Gpio14Mode = (PEEK(ptGpio14Cfg)&0xFFFFFFEF) | 0xC;
POKE(ptGpio14Cfg, Gpio14Mode);
//start Count1
eRslt = Drv_TimStartTimer(ptRscE->tRem.phTim1);
//GPIO14 PWM
ptGpio14Cfg->mode = 3;
M T
Hilscher Gesellschaft für Systemautomation mbH
Mixing up functions again? Why use rX_TimGetTime() on a HW Timer, that was setup with Drv_TimStartTimer?
When using HW Timers "Drv_Tim* is the way to go":
When using SW Timers "rX_Tim*" is the right choice:
Regards
MT