TriCore TC27D STM(System Timer)

HW: ShieldBuddy TC275

There are as many STM modules as there are CPUs in the system. Thus each CPU can use one STM for its time base

Related header

  • IfxStm_cfg.h: STM on-chip implementation data.
  • IfxStm.h: STM basic functionality.
  • IfxStm_Timer.h: STM TIMER details.

Examples

info

ํด๋”๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•œ ๊ฒฝ์šฐ clean projet ํ›„, ๋‹ค์‹œ ๋นŒ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

0_Src/AppSw/Tricore/TC27D_lib/Config/Ifx_IntPrioDef.h๋ฅผ ๋งŒ๋“ค๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

#pragma once
#define IFX_INTPRIO_STM0_SR0 10

์ฃผ๊ธฐ์ ์ธ ํ•จ์ˆ˜ ํ˜ธ์ถœ

#include "IfxCpu.h"
#include "IfxPort_Io.h"
#include "IfxPort_PinMap.h"
#include "IfxScuWdt.h"
#include "IfxStm.h"
#include "Ifx_IntPrioDef.h"
#include "Ifx_Types.h"
IfxCpu_syncEvent cpuSyncEvent = 0;
Ifx_STM * stmSfr;
IfxStm_CompareConfig stmConfig;
// P10.2 ํ•€์„ OUTPUT์œผ๋กœ ์„ค์ •.
const IfxPort_Io_ConfigPin configPin[] = {
{&IfxPort_P10_2,
IfxPort_Mode_outputPushPullGeneral,
IfxPort_PadDriver_cmosAutomotiveSpeed1},
};
const IfxPort_Io_Config conf
= {sizeof(configPin) / sizeof(IfxPort_Io_ConfigPin),
(IfxPort_Io_ConfigPin *)configPin};
IFX_INTERRUPT(stm0Sr0ISR, 0, IFX_INTPRIO_STM0_SR0) {
IfxStm_clearCompareFlag(stmSfr, stmConfig.comparator);
IfxStm_increaseCompare(stmSfr, stmConfig.comparator, stmConfig.ticks);
// ํ•จ์ˆ˜ ํ˜ธ์ถœ
IfxPort_setPinState(&MODULE_P10, 2, IfxPort_State_toggled);
}
void STM0_init(void) {
stmSfr = &MODULE_STM0;
IfxStm_initCompareConfig(&stmConfig);
// configure to generate interrupt every 100 us
sint32 ticks = IfxStm_getTicksFromMicroseconds(stmSfr, 100);
stmConfig.ticks = ticks;
stmConfig.triggerPriority = IFX_INTPRIO_STM0_SR0;
stmConfig.typeOfService = IfxSrc_Tos_cpu0;
IfxStm_initCompare(stmSfr, &stmConfig);
}
int core0_main(void) {
IfxCpu_enableInterrupts();
/*
* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdog in the demo if it is required and also service the
* watchdog periodically
* */
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Cpu sync event wait*/
IfxCpu_emitEvent(&cpuSyncEvent);
IfxCpu_waitEvent(&cpuSyncEvent, 1);
// ํ•€ ์„ค์ • ์ ์šฉ.
IfxPort_Io_initModule(&conf);
STM0_init();
while(1) {
}
return 1;
}
Last updated on