NXP S32K1 MCAL DMA配置

作者:Stephen Du

免责声明: 本文为个人学习笔记及总结,仅代表个人观点,尽可能保证内容准确性。复制/转发请注明来源/作者。

欢迎添加微信交流学习。

在这里插入图片描述

1.DMA仲裁机制

固定优先级仲裁(fixed priority arbitration): 用户对每个通道设置一个明确优先级,优先处理优先级高的通道。

循环仲裁(round robin arbitration): 从通道号大的开始执行,依次到通道号小的通道,忽略优先级。

注意这个设置是全局的,针对DMA所有逻辑通道。

默认为固定优先级仲裁机制。

EB配置如下图:

Mcl
MclConfigSet
DMA Instance
Round Robin Channel Arbitration

2.EB配置流程

由于DMA在标准中不属于标准模块,所以NXP的MCAL中将DMA归属于Mcl模块里。

2.1使能DMA

在这里插入图片描述
其余选项根据需要进行选择(可选)。

2.2使能通道中断(可选)

如果你不需要使用中断模式,忽略本章节。
在这里插入图片描述

2.3通道配置

在这里插入图片描述
上图中第一和第二个窗口默认是有实体的,如果没有,请点击工具区(上图中红框部分)绿色加号进行添加。第三个窗口默认没有,需要根据自己需要进行添加,使用几个通道就添加几个实体。

上图第二个窗口中Round Robin Channel Arbitration选项见前面“DMA仲裁机制”章节的解释。

某些配置项如果可以显示完全,可直接配置,如上图中中间的配置窗口,但是某些配置由于配置项太多,显示不全,需要进入进行配置,如上图中第一个窗口和第三个窗口,进入方式只需双击上图中手形图标处即可。

上图中最后一个窗口双击相应逻辑通道进入进行详细配置。如下图:
在这里插入图片描述
上图绿框部分可以保持默认分配的值,红框部分通常为必选项,其余选项根据需要进行勾选。

如果使用的循环仲裁模式,优先级设置可忽略,否则需要根据相应外设需要进行设置,比如SPI模块要求Rx通道的优先级大于Tx通道的优先级。优先级取值范围:0~15,数字越优先级越

其中Notification选项可以是用户的任意函数,但有时候需要注册一些特殊的函数。如这里的示例就是SPI模块使用DMA中断模式时,需要将SPI模块的中断函数注册到这里。

### S32K1 Microcontroller MCAL CAN Configuration and Usage #### Overview of the MCAL Layer The Microcontroller Abstraction Layer (MCAL) serves as an interface between hardware drivers and higher-level software layers, ensuring that applications can interact with different microcontrollers without needing to know specific details about each one. For the S32K1 series, this layer includes various components such as microcontroller drivers, memory drivers, communication drivers like CAN, I/O drivers, and cryptographic algorithm drivers[^4]. #### Hardware Setup for CAN Communication To configure the CAN module on the S32K144 using EB tools within an AUTOSAR environment involves several steps focused primarily around setting up the physical connections first. This means properly connecting all necessary pins according to the datasheet specifications so that the CAN transceiver operates correctly alongside the controller. #### Configuring CAN Module via MCAL Files Once the hardware setup is complete, attention turns towards configuring the CAN module through appropriate settings defined inside MCAL files. These configurations include enabling the CAN peripheral itself along with defining baud rates, acceptance masks/filters, buffer sizes among other parameters essential for establishing reliable data exchange over a network bus system[^2]. Here's how these configurations might look when implemented programmatically: ```c // Example C code snippet showing initialization routine for CAN module. void InitCanModule(void){ Can_ConfigType *canConfigPtr; // Initialize CAN Driver Can_Init(canConfigPtr); // Set Baudrate Prescaler Value Can_SetBaudRatePrescaler(CAN_CHANNEL_0, 5); } ``` This function initializes the CAN driver by passing it a pointer to its configuration structure (`Can_ConfigType`). It also sets the desired bit timing value which affects transmission speed across nodes connected via CAN networks. #### Implementing Message Transmission and Reception Functions After initializing the CAN module successfully, developers need functions capable of sending messages out onto the wire while simultaneously listening for incoming frames from remote devices attached at opposite ends of said wires. Such operations are facilitated thanks largely due to standardized APIs provided under the umbrella term "service interfaces," part of what makes working within an AUTOSAR framework advantageous compared against more traditional approaches where everything must be coded manually or sourced externally. Below demonstrates simple implementations of both transmit/receive routines based upon typical use cases involving automotive electronics systems built atop platforms supporting AUTOSAR standards: ```c // Function prototype declarations Std_ReturnType TransmitMessage(const PduIdType id, const uint8* sduPtr, const PduLengthType length); Std_ReturnType ReceiveMessage(PduIdType id, uint8* rxBufPtr, PduLengthType* lengthPtr); // Implementation example for transmitting message Std_ReturnType TransmitMessage(const PduIdType id, const uint8* sduPtr, const PduLengthType length){ Std_ReturnType ret; /* Call actual API */ ret = Can_Write(id,sduPtr,length); return ret; } // Implementation example for receiving message Std_ReturnType ReceiveMessage(PduIdType id,uint8*rxbuff,PduLengthTypelengthptr){ Std_ReturnType ret; /* Call actual API */ ret=Can_Read(id,rxbuff,*lengthptr); return ret; } ``` These snippets illustrate basic methods used during development phases aimed specifically toward handling outgoing/incoming packets efficiently yet reliably enough even under harsh environmental conditions often encountered throughout real-world deployments found commonly associated with vehicular telematics solutions today. --related questions-- 1. What are some common issues faced while configuring CAN modules in S32K1xx controllers? 2. How does one troubleshoot problems related to CAN communication failures after completing initial setups? 3. Are there any differences between standard CAN and CAN FD configurations concerning S32K families' implementation strategies? 4. In terms of performance optimization, what factors should be considered when fine-tuning CAN settings for best results?
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值