Start OSM TOM from periodically TOM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Curious
Level 2
Level 2
25 sign-ins First like received 5 replies posted
Hello,

I'm trying to read 6 ADC Values at 6 different times. To do that i want one periodically PWM that can reset the other timers. With the CM0/1 registers of three other TOM CH i want to trigger three ADCTRICOUT.

So to start i wanted to implement the periodically PWM, that triggers one other PWM.
To do that i enabled the one shot mode and wanted to start it in the interrupt of the Base PWM.
The program goes in the interrupt, sets the CN registery to a value, but the second TOM doesnt give an output on the Oszilloscope.


According to the User Manual i thought by setting the CN register of the OSM PWM it starts working.


I would appreciate if you could help me to understand what i am missing and if this is actually the "right" way to handle this.

http://doc.tasking.com/act/illd_1_0_0_11_0/TC27xC/html/group___ifx_lld___gtm___tom___timer___usage.h...
In this Documentation it looks like no interrupt is neccessary. How can i apply this?

Thanks in advance.

#include "TOM.h"
#include "Ifx_Types.h"
#include "IfxGtm_Tom_Pwm.h"
#include "IfxPort.h"
#include "IfxStm.h"

#define ISR_PRIORITY_TOM 40
#define BASEPERIOD 100 //Baseperiod in us
#define FIRSTPERIOD 40
#define BASETIMER IfxGtm_TOM0_0N_TOUT9_P00_0_OUT //Basetimer auf P00, 0 (EVAL: PIN 25)
#define FIRSTTIMER IfxGtm_TOM0_1N_TOUT10_P00_1_OUT //Timer der ersten Messung auf P00, 1 (EVAL: PIN 27)

IfxGtm_Tom_Pwm_Config g_tomConfig;
IfxGtm_Tom_Pwm_Driver g_tomHandle;

IfxGtm_Tom_Pwm_Config g_tomConfigfirst;
IfxGtm_Tom_Pwm_Driver g_tomHandlefirst;

IfxGtm_Tom_Pwm_Config *testConfig; /* Pointer to config-struct, for Channel-functions */
IfxGtm_Tom_Pwm_Driver *testDriver; /* Pointer to driver-struct, for Channel-functions */

Ifx_GTM_TOM *tomSFR; /* Pointer to TOM-struct for Tom-Channel-Functions*/

IFX_INTERRUPT(ISRGtmTom, 0, ISR_PRIORITY_TOM);

uint16 getTicksFromMicrosec(uint16);

/* Interrupt Service Routine of the BASETIMER TOM */
void ISRGtmTom(void)
{
IfxGtm_Tom_Ch_getChannelPointer(tomSFR, g_tomConfigfirst.tomChannel)->CN0.B.CN0 = 100;
GTM_TOM0_CH0_IRQ_NOTIFY.B.CCU1TC = 1; // re-enable interrupt line (Nofity Reg)
}

void initGtmTomBaseTimer()
{
IfxGtm_enable(&MODULE_GTM); //Enable General Time Module
IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_FXCLK); //Set CMU Clock 0 frequency

IfxGtm_Tom_Pwm_initConfig(&g_tomConfig, &MODULE_GTM); //init default parameter

g_tomConfig.tom = BASETIMER.tom; //Output Port festlegen
g_tomConfig.tomChannel = BASETIMER.channel; //Output Channel festlegen
g_tomConfig.pin.outputPin = &BASETIMER; //Set selected Pin as output
g_tomConfig.synchronousUpdateEnabled = TRUE; //update CN/CM on next dutyCycle
// g_tomConfig.dtmClockSource = IfxGtm_Dtm_ClockSource_cmuClock0; //CMU_FXCLK0 (if DTM is connected to TOM) as clock source, da evtl DTM nutzen (100MHz)
g_tomConfig.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk0; //Clock div/1
g_tomConfig.period =getTicksFromMicrosec(BASEPERIOD); //Periodendauer (CM Register) in Ticks und nicht in s!!
g_tomConfig.dutyCycle = getTicksFromMicrosec(BASEPERIOD)/2; //Dutycycle

//Interrupt Config
g_tomConfig.interrupt.ccu1Enabled = TRUE; //Interrupt sobald CN CMx erreicht
g_tomConfig.interrupt.mode = IfxGtm_IrqMode_level; //Mode
g_tomConfig.interrupt.isrProvider = IfxSrc_Tos_cpu0; //Ausführende CPU
g_tomConfig.interrupt.isrPriority = ISR_PRIORITY_TOM; //Priority

//Erzeugen eines Triggers, um die anderen Timer zu steuern
testDriver = &g_tomHandle; /* Pointer to global variable */
testConfig = &g_tomConfig; /* Pointer... -> for function argument #1 */
testDriver->gtm = testConfig->gtm;
testDriver->tomIndex = testConfig->tom; /* see "IfxGtm_Atom_Pwm.c" for the need */

tomSFR = &testConfig->gtm->TOM[testConfig->tom]; /* variable for Atom-Channel-Functions */

Ifx_GTM_TOM_CH *tomCh = IfxGtm_Tom_Ch_getChannelPointer(tomSFR, g_tomConfig.tomChannel); /* Pointer to Channel address & Control-Register */
tomCh->CTRL.B.TRIGOUT = 1; /* enabling Master-Trigger for slaves */

IfxGtm_Tom_Pwm_init(&g_tomHandle, &g_tomConfig); // TOM mit neuer Config beschreiben
IfxGtm_Tom_Pwm_start(&g_tomHandle, TRUE);
}

void initGtmTomFirstTimer()
{
IfxGtm_Tom_Pwm_initConfig(&g_tomConfigfirst, &MODULE_GTM);

g_tomConfigfirst.tom = FIRSTTIMER.tom; //Output Port festlegen
g_tomConfigfirst.tomChannel = FIRSTTIMER.channel; //Output Channel festlegen
g_tomConfigfirst.pin.outputPin = &FIRSTTIMER;
g_tomConfigfirst.synchronousUpdateEnabled = TRUE; //Update der Periode/Dutycycles nach vollendeter Periode
// g_tomConfigfirst.dtmClockSource = IfxGtm_Dtm_ClockSource_cmuClock1; //CMU_FXCLK0 (if DTM is connected to TOM) as clock source, da evtl DTM nutzen (100MHz)
g_tomConfigfirst.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk0; //Clock div/1
g_tomConfigfirst.period =getTicksFromMicrosec(FIRSTPERIOD); //Periodendauer (CM Register) in Ticks und nicht in s!!
g_tomConfigfirst.dutyCycle = getTicksFromMicrosec(FIRSTPERIOD)/2; //Dutycycle

tomSFR = &testConfig->gtm->TOM[testConfig->tom]; /* variable for Atom-Channel-Functions */

Ifx_GTM_TOM_CH *tomCh = IfxGtm_Tom_Ch_getChannelPointer(tomSFR, g_tomConfigfirst.tomChannel); /* Pointer to Channel address & Control-Register */
// tomCh->CN0.B.CN0;
tomCh->CTRL.B.OSM = 1; /* enabling One time up mode, bitwise access to register */
tomCh->CTRL.B.RST_CCU0 = 1; /* reset counter register (CN0) on TRIG_[x-1] (BASETIMER) */
// tomCh->CTRL.B.OSM_TRIG = 1; //If a channel is configured to one-shot mode and configuration bit OSM_TRIG is set to 1, the trigger signal OSM_TRIG (i.e. TRIG_[x-1] or TIM_EXT_CAPTURE(x)) triggers start of one pulse generation.

IfxGtm_Tom_Pwm_init(&g_tomHandlefirst, &g_tomConfigfirst); //TOM mit neuer Config beschreiben
IfxGtm_Tom_Pwm_start(&g_tomHandlefirst, TRUE); //TOM starten
}

0 Likes
0 Replies