基于TC275 完成三核轮流控制LED小灯
使用TC275的三个核心,轮流休眠待机,分别控制板卡上的LED灯,如core0检测按键按下,唤醒core1翻转LED1,一秒后,唤醒core2翻转LED2,系统休眠
标签
嵌入式系统
TC275
Funpack2-2
aaaaaaaaaa
更新2022-10-13
安徽师范大学
544

内容介绍

一、AURIX TM TC275 lite 套件硬件介绍
AURIX TM TC275 lite 套件配备了基于 32 位单芯片 AURIX ™M Tricore ™M的微控制器 Aurix ™M TC275。 它可以与一系列开发工具一起
使用,包括 AURIX ™M Development studio (Tool overview - Infineon Developer Center)、英飞凌免费的基于 Eclipse 的 IDE(Eclipse Downloads The Eclipse Foundation),或来自 Hightec/PLS/lnfineon 的基于 Eclipse 的"FreeEntryToolchain"。
AURIX ™M TC275lite 套件拥有丰富的外设模块。
电源模块
•稳压器 5V 至 3.3V
WIFI/BLE连接器
•用于 WIFI/BLE 的 Mikrobus连接器
CAN通信模块
•英飞凌CAN 收发器 TLE9251VSJ 和CAN 连接器
LED指示模块
•电源指示灯 (D5)
• LED D1/D2 用于 ADBUS7/4 和LED3用于 ESRO 信号(低电平有效)
电位器控制模块
•电位器 (10 kOhm)和可焊接的0 Ohm 电阻器 (0805 英制中的 R33)

Arduino连接模块
• Arduino 连接器
• Arduino ICSP 连接器
• Arduino 连接器(数字)
•Arduino 针连接器(电源和模拟输入)

FtG5c2StSC_iPgk-GlEYzhotwYQI

二、设计整体思路

Fg_66w5WDn7rI9SYia9TwEd8OP2F

当没有按下按键时三个核处于休眠状态,有CPU0主导的STM0中断不断在检测按键是否按下,若检测到按键按下,唤醒CPU1。CPU1翻转LED1,并且运行由CPU2主导的STM1中断。在STM1中断中,唤醒CPU2,CPU2再次翻转LED1。

三、各功能对应的主要代码片段及说明

1.将三核设置为闲置状态:

IfxCpu_setCoreMode(&MODULE_CPU0, IfxCpu_CoreMode_idle);
IfxCpu_setCoreMode(&MODULE_CPU1, IfxCpu_CoreMode_idle);
IfxCpu_setCoreMode(&MODULE_CPU2, IfxCpu_CoreMode_idle);

参照英飞凌官网文件“SCU_Power_Down_Idle_1 for KIT_AURIX_TC275_LK Power saving in CPU idle mod” “Idle, Sleep or Standby are supported as power consumption modes. The Idle is specific to each CPU whereas the Sleep and Standby modes influence the complete system”闲置模式针对的是单核,而睡眠模式和待机模式针对的是全部的工作。且在闲置模式下,若产生STM中断CPU将返回正常的运行模式。

2.按键状态检测:

IfxPort_getPinState(BUTTON)

3.小灯状态翻转:

IfxPort_togglePin(LED);  

4.设置STM中断:

void initStm0(void)
{
    IfxStm_Timer_Config timerConfig;                                /* Timer configuration structure                */

    IfxStm_Timer_initConfig(&timerConfig, &MODULE_STM0);            /* Initialize it with default values            */

    timerConfig.base.frequency = 20;                                 /* Interrupt rate every STM_PERIOD seconds      */
    timerConfig.base.isrPriority = ISR_PRIORITY_STM;                /* Interrupt priority                           */
    timerConfig.base.isrProvider = IfxSrc_Tos_cpu0;                 /* CPU0 to trigger the interrupt                */
    timerConfig.comparator = IfxStm_Comparator_0;                   /* Comparator 0 register is used                */

    IfxStm_Timer_init(&g_stmTimer0, &timerConfig);                   /* Use timerConfig to initialize the STM        */
    IfxStm_Timer_run(&g_stmTimer0);
}

void initStm1(void)
{
    IfxStm_Timer_Config timerConfig;                                /* Timer configuration structure                */

    IfxStm_Timer_initConfig(&timerConfig, &MODULE_STM1);            /* Initialize it with default values            */

    timerConfig.base.frequency = 1;                                 /* Interrupt rate every STM_PERIOD seconds      */
    timerConfig.base.isrPriority = ISR_PRIORITY_STM;                /* Interrupt priority                           */
    timerConfig.base.isrProvider = IfxSrc_Tos_cpu2;                 /* CPU2 to trigger the interrupt                */
    timerConfig.comparator = IfxStm_Comparator_0;                   /* Comparator 0 register is used                */

    IfxStm_Timer_init(&g_stmTimer1, &timerConfig);                   /* Use timerConfig to initialize the STM        */
}

参考英飞凌官方提供的参考文件,

“base.frequency – to define the frequency at which the interrupts are generated
– base.isrPriority – to define the priority of the interrupt generated by the STM on compare 
match. It can be a value from 0 to 255, with 0 meaning interrupt is disabled and 255 is the 
highest priority
– base.isrProvider – to define the service provider responsible for handling the interrupt. 
This can be any of the available CPUs or the DMA
– comparator – to define the used comparator”

在调用STM中断时,先对其中的参数进行初始化:“base.frequency”设置中断产生的周期;

“base.isrPriority”设置中断的优先级,可设置在0—255之间,数越高说明优先级越高;

“base.isrProvider”决定服务由哪个模块产生,可为CPUs或者DMA;以及“comparator”

设置两个STM中断,分别为STM0,与STM1,STM0由CPU0产生,作用为检测按键是否按下,当检测到按键按下时,唤醒CPU1,执行代码使小灯亮,运行STM1,STM1由核2产生,并且运行周期为1s,在STM1中断中,唤醒核2,并且关断STM1中断。在核2中,执行代码使小灯灭,并且再次使三核进入休眠状态。

四、AURIX TM TC275 lite 套件任务完成情况:

任务:使用TC275的三个核心,轮流休眠待机,分别控制板卡上的LED灯,如core0检测按键按下,唤醒core1翻转LED1,一秒后,唤醒core2翻转LED2,系统休眠

1.没有按下按钮时三核处于休眠状态

FvdGijpbur817qJjBJiBDATmvb5r

2.按下按钮,CPU1被唤醒,小灯状态翻转,并且持续1s

FmA7tp7S1goA-Fq85_y3Epv5rtDN

3.1s后,CPU2被唤醒,小灯状态再次翻转

FvdGijpbur817qJjBJiBDATmvb5r

五、对本活动的心得体验:

通过此次FUNPACK2-2活动,以及通过完成平台所布置的任务,对英飞凌32bitTriCore™AURIX™– TC2xx多核系列对多核的运用有了再次深入的理解,在此过程中,自己仍然有许多需要去学习及探讨的地方,对TC系列的芯片的应用也有了更多的认识,很感谢平台给自己这次学习的机会。

附件下载

GPIO_LED_Button_1_KIT_TC275_LK.zip

团队介绍

评论

0 / 100
查看更多
目录
硬禾服务号
关注最新动态
0512-67862536
info@eetree.cn
江苏省苏州市苏州工业园区新平街388号腾飞创新园A2幢815室
苏州硬禾信息科技有限公司
Copyright © 2023 苏州硬禾信息科技有限公司 All Rights Reserved 苏ICP备19040198号