当前位置: 首页 > news >正文

【英飞凌TC364】点亮LED灯

一、简单介绍

英飞凌单片机中,IO口被称作port。

其框架图如下所示:

有个比较有意思的特性是当port被配置成输出模式时,也能通过读Pn_IN寄存器获取port的电平状态。作为输出时,最多可以复用成7种模式。

二、开发

打开ADS,新建工程。

笔者原理图设置8个LED分别连接P2.0至P2.7。

打开pin mapper。

笔者使用的是TC364_DP 64F300W封装是LQFP144。

配置完毕点击右上角generate code。

生成的代码在这里。

aurix_pin_mappings.h

/** Generated by TASKING Pin Mapper for AURIX* - device  : TC36XPD* - package : LQFP144*//** Instructions on how to build this generated file and the Infineon's iLLD library with the TASKING  VX-toolset* for TriCore:* 1. Provide appropriate include paths to the compiler (-I option) to locate the iLLD library.* 2. Provide macro IFX_CFG_USE_COMPILER_DEFAULT_LINKER to the compiler (-D option) to prevent multiple*    definitions of symbol '_START' (in cstart.c and IfxCpu_CStart0.c).* 3. Disable compiler option 'Automatic inclusion of .sfr files' (-H option) to prevent macros to be redefined.*/#ifndef AURIX_PIN_MAPPINGS_H_
#define AURIX_PIN_MAPPINGS_H_/* Infineon's iLLD library include files */#include <Port/Io/IfxPort_Io.h>#include <_PinMap/IfxPort_PinMap.h>/* Symbolic names for GPIO ports */// p02_0
#define IFXCFG_PORT_LED0                        IfxPort_P02_0
#define IFXCFG_PORT_LED0_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED0_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_1
#define IFXCFG_PORT_LED1                        IfxPort_P02_1
#define IFXCFG_PORT_LED1_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED1_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_2
#define IFXCFG_PORT_LED2                        IfxPort_P02_2
#define IFXCFG_PORT_LED2_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED2_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_3
#define IFXCFG_PORT_LED3                        IfxPort_P02_3
#define IFXCFG_PORT_LED3_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED3_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_4
#define IFXCFG_PORT_LED4                        IfxPort_P02_4
#define IFXCFG_PORT_LED4_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED4_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_5
#define IFXCFG_PORT_LED5                        IfxPort_P02_5
#define IFXCFG_PORT_LED5_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED5_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_6
#define IFXCFG_PORT_LED6                        IfxPort_P02_6
#define IFXCFG_PORT_LED6_MODE                   IfxPort_Mode_outputPushPullGeneral
#define IFXCFG_PORT_LED6_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4// p02_7
#define IFXCFG_PORT_LED7                        IfxPort_P02_7
#define IFXCFG_PORT_LED7_MODE                   IfxPort_Mode_outputOpenDrainGeneral
#define IFXCFG_PORT_LED7_PAD_DRIVER             IfxPort_PadDriver_cmosAutomotiveSpeed4/* Generic port I/O configuration */#define IFXCFG_P02_0_IO_CONFIG                  { &IFXCFG_PORT_LED0, IFXCFG_PORT_LED0_MODE, IFXCFG_PORT_LED0_PAD_DRIVER }
#define IFXCFG_P02_1_IO_CONFIG                  { &IFXCFG_PORT_LED1, IFXCFG_PORT_LED1_MODE, IFXCFG_PORT_LED1_PAD_DRIVER }
#define IFXCFG_P02_2_IO_CONFIG                  { &IFXCFG_PORT_LED2, IFXCFG_PORT_LED2_MODE, IFXCFG_PORT_LED2_PAD_DRIVER }
#define IFXCFG_P02_3_IO_CONFIG                  { &IFXCFG_PORT_LED3, IFXCFG_PORT_LED3_MODE, IFXCFG_PORT_LED3_PAD_DRIVER }
#define IFXCFG_P02_4_IO_CONFIG                  { &IFXCFG_PORT_LED4, IFXCFG_PORT_LED4_MODE, IFXCFG_PORT_LED4_PAD_DRIVER }
#define IFXCFG_P02_5_IO_CONFIG                  { &IFXCFG_PORT_LED5, IFXCFG_PORT_LED5_MODE, IFXCFG_PORT_LED5_PAD_DRIVER }
#define IFXCFG_P02_6_IO_CONFIG                  { &IFXCFG_PORT_LED6, IFXCFG_PORT_LED6_MODE, IFXCFG_PORT_LED6_PAD_DRIVER }
#define IFXCFG_P02_7_IO_CONFIG                  { &IFXCFG_PORT_LED7, IFXCFG_PORT_LED7_MODE, IFXCFG_PORT_LED7_PAD_DRIVER }/* Initialization routines */extern void gpio_init_pins(void);#endif /* AURIX_PIN_MAPPINGS_H_ */

aurix_pin_mappings.c

/** Generated by TASKING Pin Mapper for AURIX* - device  : TC36XPD* - package : LQFP144*/#include "aurix_pin_mappings.h"/* GPIO pin configuration */static const IfxPort_Io_ConfigPin gpio_pin_table[] = 
{IFXCFG_P02_0_IO_CONFIG,IFXCFG_P02_1_IO_CONFIG,IFXCFG_P02_2_IO_CONFIG,IFXCFG_P02_3_IO_CONFIG,IFXCFG_P02_4_IO_CONFIG,IFXCFG_P02_5_IO_CONFIG,IFXCFG_P02_6_IO_CONFIG,IFXCFG_P02_7_IO_CONFIG
};static const IfxPort_Io_Config gpio_io_config_table = 
{sizeof(gpio_pin_table)/sizeof(IfxPort_Io_ConfigPin),(IfxPort_Io_ConfigPin*)gpio_pin_table
};extern void gpio_init_pins(void)
{IfxPort_Io_initModule(&gpio_io_config_table);
}

参考官方使用手册。

main.c

#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "Ifx_Cfg_Ssw.h"#include "aurix_pin_mappings.h"IFX_ALIGN(4) IfxCpu_syncEvent cpuSyncEvent = 0;
boolean state[8] = {1,1,1,1,1,1,1,1};void 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(&cpuSyncEvent);IfxCpu_waitEvent(&cpuSyncEvent, 1);gpio_init_pins();IfxPort_setPinLow(IFXCFG_PORT_LED0.port, IFXCFG_PORT_LED0.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED1.port, IFXCFG_PORT_LED1.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED2.port, IFXCFG_PORT_LED2.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED3.port, IFXCFG_PORT_LED3.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED4.port, IFXCFG_PORT_LED4.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED5.port, IFXCFG_PORT_LED5.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED6.port, IFXCFG_PORT_LED6.pinIndex);IfxPort_setPinLow(IFXCFG_PORT_LED7.port, IFXCFG_PORT_LED7.pinIndex);for (uint8 i = 0; i < 8; i++){state[i] = IfxPort_getPinState(&MODULE_P02, i);}while(1){}
}

点击build后编译无误。

点击flash烧录。

板子上的8个LED灯被点亮。

打断点调试。

读取到的值均变成0,即低电平。

http://www.dtcms.com/a/549643.html

相关文章:

  • LeetCode 3346.执行操作后元素的最高频率 I:滑动窗口(正好适合本题数据,II再另某他法)
  • 【STM32】FLASH闪存
  • 东莞网站关键词推广义乌百度推广公司
  • Spring远程调用与Web服务全解析
  • 手机站喝茶影视茂名市建设银行网站
  • 青岛做网站公司排名淄博网站建设yx718
  • 303-Spring AI Alibaba NL2SQL 向量管理示例
  • 【CVPR 2025】即插即用GBC模块:小体积,大能量,重塑特征提取新范式
  • Linux系统编程 -- 进程概念(一)
  • React 入门 02:从单页面应用到多页面应用
  • 石家庄网站建设找哪家好河西网站建设优化seo
  • h5网站怎么做api对接赣州人才招聘网
  • 生产管理系统详解:物料清单bom 工序,工艺路线中的工序和工艺资源他们之间有什么关联和区别
  • 发布元服务配置应用分类、标签和资质信息(仅分发手表设备)
  • 成绩查询系统如何制作?
  • 中国建设银行信用卡官网站首页个人做商机网站如何盈利
  • springboot酒店客房管理系统设计与实现(代码+数据库+LW)
  • 交叉编译工具链深度解析 --静态库与动态库编译实战指南
  • uni-app 开发APP应用媒体处理与文件管理功能
  • 网站建设scyiyou百度竞价推广一个月多少钱
  • 基于整数MCU的FOC控制定标策略深度解析
  • [HDiffPatch] 差异算法 | `serialize_compressed_diff`
  • Pycatia二次开发基础代码解析:实例名称获取与几何显示控制技术解析
  • 小迪安全v2023学习笔记(一百四十天)—— Linux系统权限篇VulnhubPATH变量NFS服务Cron任务配合SUID
  • 做网站前端wordpress打字烟花
  • 新能源汽车动力系统拆装与检测实训MR软件介绍-比亚迪秦EV标准版
  • 力扣:214. 最短回文串(Python3)
  • 基于Jdk17+SpringBoot3AI智慧教育平台,告别低效学习,AI精准导学 + 新架构稳跑
  • 论坛网站太难做没人百度推广客户端app
  • Shell实用实例2