Funpack2-2 TC275休眠功能
AURIX Development Studio: 是一个免费的集成开发环境 (IDE),适用于基于 TriCore™ 的 AURIX™ 微控制器系列。
标签
嵌入式系统
测试
数字逻辑
Seanny
更新2022-10-09
广东金融学院
387

内容介绍

一 本板卡最终实现了什么功能

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

二 基本功能:

1、开机时core1,core2关闭,仅core0启动,并控制LED1以0.1秒的频率闪烁

2、按键按下,core0启动core1,core1关闭core0, 并控制LED2以0.2秒的频率闪烁

2、按键按下,core1启动core2,core2关闭core1,并控制LED1, LED2以0.2秒的频率闪烁。core2启动一秒钟后,系统休眠

三 项目环境:

AURIX Development Studio: 是一个免费的集成开发环境 (IDE),适用于基于 TriCore™ 的 AURIX™ 微控制器系列。 它是一个综合开发环境,包括 Eclipse IDE、C-Compiler、多核调试器、英飞凌低级驱动程序 (iLLD),没有时间和代码大小限制,可以编辑、编译和调试应用程序代码。
VS code v1.60.0: 微软开发的跨平台源代码编辑器

四 硬件:

参数KIT_AURIX_TC275_LITE家庭微控制器产品描述AURIX™ TC275 lite 套件配备了基于 32 位单芯片 AurixTM TriCoreTM 的微控制器 AurixTM TC275。它可以与一系列开发工具一起使用,包括 AURIXTM Development Studio、英飞凌免费的基于 Eclipse 的 IDE,或来自 Hitecs/PLS/Infineon 的基于 Eclipse 的“FreeEntryToolchain”类型评估板

五 相关代码及说明
 
1 GPIO初始化,初始化LED1,LED2和按键的GPIO,为后面的使用做准备
void configLED2(void)
{
    /* Set Port Pin 00.5 to output mode and turn off the LED (LED is low-level active) */
    IfxPort_setPinModeOutput(LED2, IfxPort_OutputMode_pushPull, IfxPort_OutputIdx_general);
    IfxPort_setPinHigh(LED2);
    IfxPort_setPinMode(BUTTON, IfxPort_Mode_inputPullUp);
}
void configLED(void)
{
    /* Set Port Pin 00.5 to output mode and turn off the LED (LED is low-level active) */
    IfxPort_setPinModeOutput(LED1, IfxPort_OutputMode_pushPull, IfxPort_OutputIdx_general);
    IfxPort_setPinHigh(LED1);
}
2 添加按键去除抖动函数,按键释放的时候才保证按键的输入足够稳定
int if_key_is_pushed(void)
{
    /* With the routine getPinState() the value of a particular pin can be retrieved. This
* function can be used to retrieve any port state by just specifying the port number
* as illustrated.
*/
    if(IfxPort_getPinState(BUTTON) == 0)
    {
        /* With the routine setPinState() the state of the port can be set to drive either
* LOW or HIGH. This function can be used to retrieve any port state by just
* specifying the port number as illustrated.
*/

        waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, WAIT_TIME));
        if (IfxPort_getPinState(BUTTON) == 0){

            IfxCpu_enableInterrupts();                                          /* Enabling interrupts as ISR disables it   */
            //            IfxStm_Timer_acknowledgeTimerIrq(&g_myTimer);                       /* IR acknowledge and set new compare value */

            //            if(setIdle == TRUE)
            //            {
            //                IfxCpu_setCoreMode(&MODULE_CPU0, IfxCpu_CoreMode_idle);         /* Set CPU0 in IDLE mode                    */
            //                setIdle = FALSE;
            //            }
            //            else
            //            {
            //                IfxCpu_setCoreMode(&MODULE_CPU0, IfxCpu_CoreMode_run);         /* Set CPU0 in IDLE mode                    */
            //                setIdle = TRUE;
            //            }
            while (1) {
                if (IfxPort_getPinState(BUTTON) != 0) {
                    return 1;
                }
            }
        }
    }
    return 0;

}
3 设置CPU0,开机时core1,core2关闭,仅core0启动,并控制LED1以0.1s的频率闪烁,并持续监听按键的按下,如果按键按下则调用函数启动core1.
int core0_main(void)
{
    IfxCpu_enableInterrupts();

    /* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
     * Enable the watchdogs and service them periodically if it is required
     */
    IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
    IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());

    /* Wait for CPU sync event */
    IfxCpu_emitEvent(&g_cpuSyncEvent);
    IfxCpu_waitEvent(&g_cpuSyncEvent, 1);

    /* Initialize Power Down Idle Training */
    configLED();
    set_c1_idle(); //set cpu1 to idle
    set_c2_idle(); //set cpu2 to idle
//    configSystemTimer();

    while(1)
    {
        if (if_key_is_pushed() == 1) {
            set_c1_run();
        }
        for(uint32 i = TICKS_TO_WAIT; i > 0; i--)
        {
            /* Wait */
        }
        toggleLED();
    }

    return (1);
}
4 设置CPU1,启动时关闭core0, 并控制LED2以0.2s的频率闪烁,并监听按键按下。如果按键按下,启动core2。
int core1_main(void)
{
    IfxCpu_enableInterrupts();
    
    /* !!WATCHDOG1 IS DISABLED HERE!!
     * Enable the watchdog and service it periodically if it is required
     */
    IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
    
    /* Wait for CPU sync event */
    IfxCpu_emitEvent(&g_cpuSyncEvent);
    IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
    
    configLED2();


    while(1)
    {
        if (if_key_is_pushed() == 1) {
            set_c2_run();
        }
        for(uint32 i = TICKS_TO_WAIT; i > 0; i--)
        {
            /* Wait */
        }
        toggleLED2();
    }

    return (1);
}
5 设置core2,core2启动后关闭core1,并控制LED1,LED闪烁,一秒钟后,系统休眠
int core2_main(void)
{
    IfxCpu_enableInterrupts();
    
    /* !!WATCHDOG2 IS DISABLED HERE!!
     * Enable the watchdog and service it periodically if it is required
     */
    /*
    IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
    IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
    */
    
    /* Wait for CPU sync event */
    /*
    IfxCpu_emitEvent(&g_cpuSyncEvent);
    IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
    */
    configLED();
    configLED2();

    while(1)
    {
        for(uint32 i = TICKS_TO_WAIT; i > 0; i--)
            {

            }
            toggleLED();
//            toggleLED2();
            // configSystemTimer();
            initStm();
            sleep_count = sleep_count+1;
            if (sleep_count > 20) {
                configSystemTimer();
                initTom();
                set_sleep();
            }
            // set_sleep();
//          control_CPU_0();
    }
    return (1);
}

 

六 实现功能的演示及说明
 
1 开机时

我们可以看到,LED1正在进行闪烁,说明core0启动成功,并且core1,core2没有启动

FluWnP0E-6GI6MUiyQ8C6lQSStM6

2 第一次按下按键后

LED1停止了闪烁,LED2进行闪烁,此时core1启动成功,并且core0进入了休眠状态

FlymOkdTxo-pFz3yY_PdRMATlm-a

3 第二次按下按键后

LED1和LED2同时进行闪烁,说明core2启动成功,core1进入了休眠状态

4 第二次按下按键1秒后

LED1和LED2同时停止闪烁,此时系统所有核心进入休眠状态

FulGUEil9a7zI94hhqfSV-iV_mdQ

七 遇到的问题
 
1 环境的配置

AURIX Development Studio安装包比较大,下载的时候出现了很多问题,可以使用加速器进行下载

2 单个核心的休眠

通过查阅用户手册可以得知,如果要使用测试的

附件下载

Cpu0_Main.zip

团队介绍

xiru

评论

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