基于MCAL的S32K312 PORT、DIO使用

本文参考“土豆萝卜丝”大佬《S32K3系列—Port Mcal配置》、《S32K3系列—DIO Mcal配置》https://blog.youkuaiyun.com/wj930211WJ/article/details/133139771
https://blog.youkuaiyun.com/wj930211WJ/article/details/133991545
参考“何飞阳”大佬《S32K3 GPIO/DIO 中断 使用介绍 —— 基于MCAL》
https://blog.youkuaiyun.com/HeFlyYoung/article/details/123682340

0、简介

相比于参考文章,本文基于S32K312 介绍PORT DIO的使用,主要是记录开发流程,本文基于《基于MCAL的S32K3 MCU使用》的工程,环境如下:

MCU:NXP S32k312

RTD版本:SW32K3_S32M27x_RTD_R21-11_4.0.0_D2311

EB版本:tresos Studio 29.0

***本文目前主要是记录配置,后期不断完善配置内容的含义***

1、模块简介

Port
Dio digital IO
MSCR Multiplexed Signal Configuration Register

在这里插入图片描述

DIO port:表示一组DIO引脚(硬件上就打包好的,比如Port A_L表示PTA0–PTA15)
DIO channel:表示一个通用输入输出引脚。
DIO channel group:表示一个逻辑组里的多个相邻引脚,一个DIO channel group是一个DIO port的子集。(比如一个16bit的port中的2–6引脚)

2、新建工程

2.1 新建工程

本文基于《基于MCAL的S32K3 MCU使用》的工程。

2.2 添加相关模块

在这里插入图片描述

2.3 PORT配置

2.3.1 General

在这里插入图片描述
在这里插入图片描述

2.3.2 PortContainer

在这里插入图片描述
在这里插入图片描述
添加所需PIN后,进入配置项

### S32K312 Microcontroller with FreeRTOS Operating System Tutorials and Resources #### Overview of Integration between S32K312 and FreeRTOS The integration of the S32K312 microcontroller with the FreeRTOS operating system involves configuring hardware timers, setting up interrupts properly to ensure real-time task scheduling works efficiently. The configuration parameters such as `configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY` set at a value like 0x01 indicate that only interrupts with priority levels less than or equal to this will be allowed during critical sections[^2]. #### Setting Up Peripheral Interrupts on S32K312 under FreeRTOS For peripheral interrupt setup within an environment using FreeRTOS, specific configurations are necessary. When working with peripherals like GPIO through PORT/DIO modules, ensuring these can trigger interrupts without disrupting RTOS operations is crucial. This includes defining appropriate priorities so they do not interfere with higher-priority tasks managed by FreeRTOS. ```c // Example Configuration in FreeRTOSConfig.h #define configPRIO_BITS 4 #define configMAX_API_CALL_INTERRUPT_PRIORITY (0x01 << (8 - configPRIO_BITS)) ``` This ensures compatibility between external device handling via MCAL layers while maintaining stable multitasking capabilities provided by FreeRTOS. #### Utilizing Periodic Interrupt Timer (PIT) for Time Management Using STM's System Timer Module PIT allows precise timing control required for many applications running atop FreeRTOS. By initializing one of the available channels from this module, developers gain access to reliable timekeeping services essential for implementing delays, timeouts, or scheduled events accurately[^1]. ```c /* Initialize PIT Channel */ void vInitPit(void){ pit_config_t pitInfo; /* Configure channel settings here */ PIT_Init(PIT_BASEADDR, &pitInfo); } ``` #### Practical Development Flow Based on MCAL Layer When developing projects involving both S32K312 and FreeRTOS, following structured procedures helps streamline development processes. Starting from establishing basic communication interfaces over UART or CAN buses down to fine-tuning performance aspects related to power management—all benefit significantly when built upon well-documented frameworks like those described in resources concerning porting guides specifically tailored towards NXP’s S32 family processors[^3]. --related questions-- 1. How does adjusting `configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY` affect overall system responsiveness? 2. What considerations should be taken into account when integrating additional drivers alongside existing ones already utilizing high-priority ISRs? 3. Can you provide examples where improper synchronization might lead to issues even after correctly configuring NVIC priorities according to best practices outlined above? 4. In what scenarios would it make sense to use multiple instances of PIT instead of relying solely on SysTick for timing purposes within embedded systems powered by FreeRTOS?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值