TIDUA05B June 2015 – March 2025
The example firmware is developed and compiled for the Piccolo TMS320F28069M and leverages the peripheral modules outlined in Figure 5-1.
The firmware leverages C2000 controlSUITE™. The firmware basically consists of three functional blocks. The F28069M framework, as outlined in Figure 5-2, the algorithm to synchronously sample the required data and calculate the interpolated angle, as well as the UART terminal based user interface.
Figure 5-2 Flowchart of Sin/Cos Encoder FrameworkThe TMS320F28069M framework initializes the TMS320F26069M CPU clock to 80 MHz, the GPIO multiplexers, the peripherals like SPI-A, SCI-A (UART), the ePWM1-based periodic timer and interrupt, the embedded 12-bit dual S/H ADC. It also configures the external 16-bit dual ADC ADS8354 through SPI-A as outlined in Section 4.3.2.4. The SPI-A is configured as SPI Master with the serial clock of 10 MHz. This is the maximum SPI clock for the Piccolo F28069M. For other processors like Sitara AM437x or Delfino F287x, the SPI clock can be up to 24 MHz.
After initialization the program invokes the UART-based user interface and serves the period interrupt service routine (ISR). The period ISR implements the synchronized data capture, calculation of intermediate phase, and total interpolated angle based on both the external 16-bit ADC ADS8354 and the internal 12-bit ADC. It follows the algorithms outlined in Section 1. The code is written with 32-bit integer fractional Q28 numbers using TI’s IQmath library. The advantage of 32-bit fractional numbers versus
32-bit IEEE floating point is that the resolution remains constant independent of the data range. Since the data range is limited from 0 to 1.0 for the angle (per unit), as well as for the ADC input data, which is scaled to maximum of ±5 (V), Q28 numbers with an integer range ±8.0 provide enough headroom, while accuracy remains constant for all data.
The flowchart of the ISR is shown in Figure 5-3.
Figure 5-3 Flowchart of Sin/Cos Encoder Main ISR With Interpolated Angle Calculation