主要内容

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, click the index entry of the AdcHwUnit_0 parameter. In the AdcHwUnit pane, 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 Delete entry in EB Tresos Studio tool.

    To configure AdcChannel_0, 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 Arrow button to back to previous menu EB Tresos Studio tool.

  4. The motor control example does not use any software triggers. To delete software triggers, in the AdcGroup tab, select AdcSWGroup, and click Delete entry in EB Tresos Studio tool.

  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 Delete entry in EB Tresos Studio tool.

    • In the AdcResRegDefinition tab, select 1 and click Delete entry in EB Tresos Studio tool.

  7. The motor control example uses the GTM trigger for the PWM block. To delete this trigger configuration for the ADC block, in the GtmTriggerTimerConfig tab, select the GtmTriggerTimerConfigGtmTrigger parameter, and click Delete entry in EB Tresos Studio tool.

    To navigate to Adc tab, click Arrow button to back to previous menu EB Tresos Studio tool twice.

  8. To add a new ADC hardware module entry , in the AdcHwUnit tab, click Add new entries in EB Tresos Studio tool. This creates a hardware module with the name AdcHWUnit_1.

    To configure the parameters of AdcHWUnit_1, 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, click on 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.

    To navigate back to the AdcHWUnit_1 tab click Arrow button to back to previous menu EB Tresos Studio tool.

  9. To configure the ADC group parameters of AdcHWUnit_1, in the AdcGroup tab, 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 Add new entries in EB Tresos Studio tool.

    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 Arrow button to back to previous menu EB Tresos Studio tool twice.

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

    This example uses the GTM trigger for the PWM block. Therefore, you do not need the GTM TOM channel. Configure the McuGtmTomAllocationConf_0 parameter to not to use this channel. In the McuHardwareResourceA tab, click the index entry. In the McuGtmTomChannelAllocationConf tab, 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, 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, click on the index entry of the parameter.

    To add a new channel entry, in the DioChannel tab, click Add new entries in EB Tresos Studio tool. Rename the channel entry to INHIBIT_FC and set its DioChannel parameter to 0.

    To navigate to DIO tab, click Arrow button to back to previous menu EB Tresos Studio tool.

  3. To add a new port, in the DioPort tab, click Add new entries in EB Tresos Studio tool. Set the DioPortId parameter of this port to 15.

    To configure parameters of this new port DioPort_4, click on its index entry. In the DioChannel tab, click Add new entries in EB Tresos Studio tool to add a new channel entry. Rename of the channel as MOTOR_ENABLE and set its DioChannel parameter to 7.

    To navigate to DIO tab, click Arrow button to back to previous menu EB Tresos Studio tool.

  4. To configure parameters of DioPort_0, 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 Add new entries in EB Tresos Studio tool. Rename this channel to TLE9180_ENABLE and set its DioChannel 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, 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 UartCTEnable, 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, click on the index of the entry IrqASCLINConfig_0.

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

    • Set IrqAsclin0ErrPrio (0 → 255) to 90

    • Set IrqAsclin2ErrPrio (0 → 255) to 0

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

    • Set IrqAsclin0TxPrio (0 → 255) to 88.

    • Set IrqAsclin2TxPrio (0 → 255) to 0.

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

    • Set IrqAsclin0RxPrio (0 → 255) to 89.

    • Set IrqAsclin2RxPrio (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, 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_3 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, select its index entry.

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

  3. To navigate to the PortContainer tab, click Arrow button to back to previous menu EB Tresos Studio tool.

  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 configure PortContainer_7 for ASCLIN transmission, in the PortContainer tab, select its index entry.

    To update the pin configuration, in the PortPin tab of the PortContainer pane, set the PortPinIn parameter of the PortPin_0 entry 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