Contenuto principale

Configure MCAL Modules and Generate Code in EB Tresos Studio

After installing the required third-party tools and generating microcontroller abstraction layer (MCAL) demo project, you must customize the MCAL demo project for the motor control application. To customize the project, you configure the peripherals such as analog‑to‑digital converter (ADC), digital input/output (DIO), and universal asynchronous receiver/transmitter (UART) along with their interrupt configuration, interrupt priorities, memory allocation, and port configurations.

After you generate the MCAL configuration in EB Tresos Studio, implement these configuration settings. For a visual walkthrough of the configuration settings, play the video.

Configure ADC

These configuration steps in EB Tresos Studio enable MCAL drivers to generate accurate, time‑synchronized analog measurements required for the control algorithms of the motor control application.

  1. To configure ADC parameters in the Adc tab, in the DemoApp project, expand Adc (Version #) and select Adc.

  2. To enable the ADC read group for synchronized and fast analog sampling, in the General tab, select the AdcReadGroupApi parameter.

  3. To configure the ADC hardware trigger parameters, in the AdcHwUnit tab, double-click the index entry of the AdcHwUnit_0 parameter. In the AdcHwUnit pane, double-click the AdcChannel tab. For this motor control example, you do not need channel 1. To delete this channel from the configuration, select AdcChannel_1 and click the Remove selected elements button .

    To configure AdcChannel_0, double-click the index entry of the parameter. In the General tab of the AdcChannel pane, set the AdcAnChannelNum parameter to G0CH0.

    To navigate to AdcHwUnit tab, click the Navigate one container upward button .

  4. The motor control example does not use any software triggers. To delete software triggers, in the AdcGroup tab, select AdcSWGroup, and click the Remove selected elements button .

  5. To configure ADC hardware group parameters, select the index entry of the AdcHwGroup parameter. In the General tab of the AdcGroup pane, configure these settings.

    • Set AdcGroupId (dynamic range) to 0.

    • Set AdcStreamingBufferMode to ADC_STREAM_BUFFER_CIRCULAR.

    • Set AdcStreamingNumSamples (1 —> 255) to 2.

    • Set AdcHwExtTrigSelect to ADC_TRIG_9_GxREQTRJ_GTM_ADCx_TRIG1.

  6. Because this example does not use channel, you must delete all channel 1 parameters.

    • In the AdcGroupDefinition tab, select the index entry 1 and click the Remove selected elements button .

    • In the AdcResRegDefinition tab, select 1 and click the Remove selected elements button .

  7. The motor control example uses the GTM trigger for the PWM block from the Embedded Coder® Support Package for Infineon® AURIX™ TC3x Microcontrollers. To delete the GTM trigger configuration in EB Tesos, in the GtmTriggerTimerConfig tab, select the GtmTriggerTimerConfigGtmTrigger parameter, and click the Remove selected elements button.

    To navigate to Adc tab, click the Navigate one container upward button twice.

  8. To add a new ADC hardware module entry, in the AdcHwUnit tab, click the Add new element with default values button . This creates a hardware module with the name AdcHWUnit_1.

    To configure the parameters of AdcHWUnit_1, double-click on its index entry.

    • In the General tab of the AdcHwUnit pane, set AdcHwUnitId to HWUNIT_ADC3.

    • To configure the channel parameters of the new ADC hardware module, in the AdcChannel tab, double-click the index entry of Adc_Channel_0. In the General tab of the AdcChannel pane, set AdcAnChannelNum to G3CH0

    • To avoid naming conflict with the channel parameters of AdcHWUnit_0, at the top of the AdcChannel pane, rename Adc_Channel_0 to Adc3Channel_0.

      EB Tresos opens a dialog box when you rename any parameter. To update the parameter references, in the Adapt References dialog box, select Yes.

    To navigate back to the AdcHWUnit_1 tab click the Navigate one container upward button .

  9. To configure the ADC group parameters of AdcHWUnit_1, in the AdcGroup tab, double-click on its index. In the General tab of the AdcGroup pane configure the following settings.

    • Set AdcGroupId (dynamic range) to 96.

    • Set AdcGroupAccessMode to ADC_ACCESS_MODE_STREAMING.

    • Set AdcGroupTriggSrc to ADC_TRIGG_SRC_HW.

    • Set AdcStreamingBufferMode to ADC_STREAM_BUFFER_CIRCULAR.

    • AdcStreamingNumSamples (1 —> 255) to 2.

    • AdcHwExtTrigSelect to ADC_TRIG_9_GxREQTRJ_GTM_ADCx_TRIG1.

  10. To add hardware triggers, in the AdcHwTrigSignal tab, click the Add new element with default values button .

    In the AdcGroupDefinition tab, set AdcGroupChannel parameter of the 0 entry to /Adc/Adc/AdcConfigSet/AdcHwUnit_1/Adc3Channel_0. To navigate back to the Adc pane, click the Navigate one container upward button twice.

  11. To configure the memory allocation parameters of the ADC, in the DemoApp project, expand Mcu (Version #) and select Mcu.

    This motor control example uses the GTM trigger for the PWM block from the Embedded Coder Support Package for Infineon AURIX TC3x Microcontrollers. Therefore, you must delete the GTM trigger configuration in EB Tesos. In the McuHardwareResourceA tab, double-click the index entry.

    In the McuGtmAllocationConf tab of the McuHardwareResourceAllocationConf pane, double-click the index entry 0.

    In the McuGtmTomChannelAllocationConf tab of the McuGtmAllocationConf pane, double-click the index entry 0.

    In the McuGtmTomChannelAllocationConf tab of McuGtmTomAllocationConf pane, set McuGtmTomChannelAllocationConf parameter of McuGtmTomChannelAllocationConf_6 to GTM_TOM_CHANNEL_NOT_USED.

  12. To configure ADC interrupt configuration parameters, in the DemoApp project, expand Irq (Version #) and select Irq.

    To configure the interrupt priority of ADC channels, in the IrqAdcConfig tab of the Irq pane, double-click the index of the IrqAdcConfig_0 parameters. In the IrqAdc0PrioConfig pane, configure the following settings.

    • Expand IrqAdc0PrioConfig and set IrqAdc0SR0Prio (0 → 255) to 19.

    • Expand IrqAdc3PrioConfig and set IrqAdc3SR0Prio (0 → 255) to 20.

Configure DIO

  1. To configure DIO parameters, in the DemoApp project, expand Dio ( Version #) and select Dio.

  2. To configure DioPort_1 parameter, in the DioPort tab, double-click on the index entry of the parameter.

    To add a new channel entry, in the DioChannel tab, click the Add new element with default values button . Rename the channel entry to INHIBIT_FC and set its DioChannelId parameter to 0.

    To navigate to DIO tab, click the Navigate one container upward button .

  3. To add a new port, in the DioPort tab, click the Add new element with default values button . Set the DioPortId (dynamic range) parameter of this port to 15.

    To configure parameters of this new port DioPort_4, double-click on its index entry. In the DioChannel tab, click the Add new element with default values button to add a new channel entry. Rename of the channel as MOTOR_ENABLE and set its DioChannelId parameter to 7.

    To navigate to DIO tab, click the Navigate one container upward button .

  4. To configure parameters of DioPort_0, double-click on its index entry. In the DioChannel tab, rename STB2 parameter to SAFE_OFF.

  5. To add a new channel entry, in the DioChannel tab, click the Add new element with default values button . Rename this channel to TLE9180_ENABLE and set its DioChannelId parameter to 11.

Configure UART

  1. To configure UART parameters, in the DemoApp project, expand UART (Version #) and select Uart.

  2. To configure UART channel parameters, in the UartChannel tab, double-click on the index entry of the UartChannel_0. In the General tab of UartChannel pane, set UartHwUnit to ASCLIN0 and UartRxPinSelection to SELECT_A_PORT14_PIN1.

  3. To enable UART pin selection, select UartCTSEnable, set UartCTSPinSelection to SELECT_CTS_A_PORT14_PIN9. Then, disable UartCTEnable.

  4. To configure the UART interrupt configuration, in the DemoApp project, expand Irq (Version #) and select Irq. In the IrqASCLINConfig tab of Irq pane, double-click the index of the entry IrqASCLINConfig_0.

  5. To set the UART transmit interrupt priority, in the General tab of the IrqASCLINConfig pane, go to the IrqAsclinPrioConfig tab, expand the IrqAsclinTxPrioConfig pane, and configure the following settings.

    • Set IrqAsclin0TxPrio (0 → 255) to 88.

    • Set IrqAsclin2TxPrio (0 → 255) to 0.

  6. To set the UART receive interrupt priority, in the General tab of the IrqASCLINConfig pane, go to the IrqAsclinPrioConfig tab, expand the IrqAsclinRxPrioConfig pane, and configure the following settings.

    • Set IrqAsclin0RxPrio (0 → 255) to 89.

    • Set IrqAsclin2RxPrio (0 → 255) to 0.

  7. To set the error interrupt priority, in the General tab of the IrqASCLINConfig pane, go to the IrqAsclinPrioConfig tab, expand the IrqAsclinErrPrioConfig pane, and configure the following settings.

    • Set IrqAsclin0ErrPrio (0 → 255) to 90

    • Set IrqAsclin2ErrPrio (0 → 255) to 0

  8. To configure memory allocation parameters for the UART, in the DemoApp project, expand Mcu (Version #) and select Mcu.

  9. In the McuHardwareResourceA tab in the Mcu pane, double-click the index 0. In the McuAsclinAllocationConf tab of the McuHardwareResourcesAllocationConf pane, configure the following settings.

    • Set McuAsclinChannelAllocationConf parameter of McuAsclinChannelAllocationConf_0 entry to ASCLIN_CH_USED_BY_UART_DRIVER.

    • Set McuAsclinChannelAllocationConf parameter of McuAsclinChannelAllocationConf_2 entry to ASCLIN_CH_NOT_USED.

Configure Ports

  1. To update the pin configuration for the peripheral blocks, in the DemoApp project, expand Port (Version #) and select Port.

  2. To configure PortContainer_9, in the PortContainer tab, double-click its index entry.

    To update the pin configuration, in the PortPin tab of the PortContainer pane, set the PortPinInitialMode parameter of the PortPin_0 entry to GPIO.

  3. To navigate to the PortContainer tab, click the Navigate one container upward button .

  4. To configure PortContainer_19, in the PortContainer tab, select its index entry.

    To update the pin configuration, in the PortPin tab of the PortContainer pane, set the PortPinDirection parameter of the PortPin_11 entry to PORT_PIN_OUT.

  5. To ensure PortContainer_7 configuration for ASCLIN transmission, in the PortContainer tab, double-click its index entry.

    In the PortPin tab of the PortContainer pane, ensure that the PortPinInitialMode parameter of the PortPin_0 entry is set to ALT2.

Generate Code in EB Tresos Studio

  1. To save the updated MCAL configuration, in the context menu, select File > Save.

  2. To verify the project, in the context menu, select Project > Verify Project.

  3. To generate code, in the context menu, select Project > Generate Project.

You integrate this code with Simulink code to generate production‑ready code and deploy it to implement field-oriented control (FOC) for a permanent magnet synchronous motor (PMSM) on Infineon AURIX™ TC3x microcontrollers. This example uses the BIFACES tool to integrate code and build the motor control project.

See Also

External Websites