Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

AURIX™ MCU: Using the AURIX™ Special Function Register Group definitions - KBA235505

AURIX™ MCU: Using the AURIX™ Special Function Register Group definitions - KBA235505

IFX_Publisher1
Community Manager
Community Manager
Community Manager
250 sign-ins First comment on KBA 250 replies posted

Community Translation: AURIX™ MCU: AURIX™ 特殊機能レジスタ(Special Function Register :SFR)グループの定義を使用する - KBA235505

Version: *A

Use the AURIX™ Special Function Register (SFR) Group when the hardware (HW) function block or sub block instances repeat multiple times. This helps in error-free and resource-efficient software development resulting in:

  • Single image of driver software that is developed to access such blocks
  • Possibility to iterate (in loop) to configure such blocks

To further detail the proposal: AURIX™ SFR C Header Files organize the registers as register groups, in the same hierarchy as they appear in HW function block. This enables encapsulation of the peripheral HW modules (C Structure representation of HW kernel register map) as shown in Figure 1.

Screenshot (53).png

Figure 1   Peripheral HW modules

Figure 2 shows the usage of grouped structures with Controller Area Network (CAN) as an example to show single software image scenario using AURIX™ TC3xx MCMCAN represented in C structure. Here, each CAN node (sub block) is instantiated as sub structure.

Screenshot (54).png

Figure 2  CAN structures

To control a CAN node, it is enough to develop single API, which takes the pointer to SFR as argument as shown in the following example:

void IfxCan_Node_setFrameMode(Ifx_CAN_N *node, IfxCan_FrameMode frameMode)
{
    switch (frameMode)
    {
    case IfxCan_FrameMode_standard:
        node->CCCR.B.FDOE = 0;
        node->CCCR.B.BRSE = 0;
        break;
    case IfxCan_FrameMode_fdLong:
        node->CCCR.B.FDOE = 1;
        node->CCCR.B.BRSE = 0;
        break;
    case IfxCan_FrameMode_fdLongAndFast:
        node->CCCR.B.FDOE = 1;
        node->CCCR.B.BRSE = 1;
        break;
    }
}

 

As shown in the code above, the first parameter in the IfxCan_Node_setFrameMode function is pointer to Ifx_CAN_N. This API with the same signature and the same image stored once in the code memory, could be used across all available CAN nodes.

Following code snippet shows how the above API could be called for node 0

IfxCan_Node_setFrameMode(&MODULE_CAN0.N[0], IfxCan_FrameMode_fdLong);

 

Note: This KBA applies to the following series of AURIX™ MCUs:

  • AURIX™ TC2xx series
  • AURIX™ TC3xx series
0 Likes
524 Views