mcu know-how

basic knowledge

SPI protocol

SPI, Serial Peripheral Interface。使MCU与各种外围设备以串行方式进行通信以交换信息。
SPI总线可直接与各个厂家生产的多种标准外围器件相连,包括FLASHRAM、网络控制器、LCD显示驱动器、A/D转换器和MCU等。

SPI接口主要应用在EEPROM、FLASH、实时时钟、AD转换器, ADC、 LCD 等设备与 MCU 间,还有数字信号处理器和数字信号解码器之间,要求通讯速率较高的场合。

TAPI protocol

TAPI(电话应用程序接口)是一个标准程序接口,它可以使用户在电脑上通过电话或视频电话与电话另一端的人进行交谈。TAPI还具备一个服务提供者接口(SPI),它面向编写驱动程序的硬件供应商。TAPI动态链接库把API映射到SPI上,控制输入和输出流量。

MCU timing

Software design is easy when the processor can provide far more computing time than the application needs. in MCU, the reality is often the opposite case. the following are some basic know-how, before we can jump into ADAS MCU/SOC issues.

scheduling sporadic and aperiodic events in a hard real-time system

A common use of periodic tasks is to process sensor data and update the current state of the real-time system on a regular basis.

Aperiodic tasks are used to handle the processing requirements of random events such as operator requests. An aperiodic task typically has a soft deadline. Aperiodic tasks that have hard deadlines are called sporadic tasks.

Background servicing of aperiodic requests occurs whenever the processor is idle (i.e., not executing any periodic tasks and no periodic tasks are pending). If the load of the periodic task set is high, then utilization left for background service is low, and background service opportunities are relatively infrequent. However, if no aperiodic requests are pending, the polling task suspends itself until its next period, and the time originally allocated for aperiodic service is not preserved for aperiodic execution but is instead used by periodic tasks

foreground-background scheduling

  • periodic tasks are considered as foreground tasks

  • sporadic and aperiodic tasks are considered as background tasks

    foreground tasks have the highest priority and the bc tasks have lowest priority. among all highest priority, the tasks with highest priority is scheduled first and at every scheduling point, highest priority task is scheduled for execution. only when all foreground tasks are scheduled, bc task are scheduled.

  • completion time for foreground task

for fg task, their completion time is same as the absolute deadline.

  • completion time for background task

when any fg task is being excuted, bc task await.

let Task Ti is fg task, Ei is the amount of processing time required over every Pi period. Hence,

1
Avg. CPU utilization for Ti is Ei/Pi

if there are n periodic tasks(fg tasks), e.g. T1, T2, … Tn

then total avg CPU utilization for fg taskes:

1
fg_cpu_util = E1/P1 + E2/P2 + ... + En/Pn

then the avg time available for execution of bg task in every unit of time is:

1
1 - fg_cpu_util

let Tb is bg task, Eb is the required processing time, then the completion time of bg task:

1
= Eb / (1 - fg_cpu_util)

in ADAS system, usually there exist bost periodic tasks(fg) and aperiodic tasks(bc), and they are corelated, fg tasks always have higher priority than bc tasks. so there is chance when a certain fg task rely on output of another bc task, which is not or partially updated due to executing priority, then there maybe some isues.

refer

Vector: Functional safety and ECU implementation

autosar OS measures task execution times

3min看懂mcu

设计定时任务系统