|
3.3kW Totem-pole PFC with SiC and XMC1404
|
Files | |
| file | communication.c |
| Communication functions. | |
| file | communication.h |
| Communication code. | |
Data Structures | |
| union | msg_t |
| struct | params_t |
Macros | |
| #define | XMC_FLASH_SECTOR_8 8 |
| #define | MASTER_KEY (1) |
| #define | UART_TRANSMIT_CLK_DIV (2) |
Functions | |
| static uint16_t | limit_range (uint16_t value, uint16_t min, uint16_t max) |
| Limit the value insight of the range between min and max. More... | |
| static void | uart_execute_cmd () |
| UART execute received command and data. More... | |
| void | uart_receive () |
| UART receive data. More... | |
| static void | uart_tx_half_word (uint8_t command, uint16_t msg) |
| UART transmit data. More... | |
| void | uart_transmit () |
| UART transmit data. More... | |
| void | load_ROM_parameters () |
| Copy parameters from ROM into an intermediate RAM area. More... | |
| void | check_RAM_parameters () |
| Check that parameters in RAM are insight of a valid range. More... | |
| uint32_t | XMC_USIC_CH_TXFIFO_GetLevel (XMC_USIC_CH_t *const channel) |
Variables | |
| const params_t * | parameters_ROM = (params_t *)(XMC_FLASH_BASE + (XMC_FLASH_BYTES_PER_SECTOR * XMC_FLASH_SECTOR_8)) |
| params_t | parameters_RAM |
| params_t | parameters_MIN_RAM |
| params_t | parameters_MAX_RAM |
| const params_t | parameters_DFLT |
| params_t | parameters_MIN |
| params_t | parameters_MAX |
| static uint8_t | msg_cnt = 100 |
| static msg_t | UART_rx_buffer |
| const params_t * | parameters_ROM |
| const params_t | parameters_DFLT |
| params_t | parameters_RAM |
Converter ID | |
| #define | CONVERTER (5) |
| #define | VERSION_BITS (8) |
| #define | VERSION (1) |
| #define | SUB_VERSION (0) |
Serial communication commands | |
Communication blocks of 3 bytes. 1 byte command, 2 bytes payload. |----------—|----------—|----------—|----------—|----------—| 0x55 CMD DATA_0 DATA_1 CRC | |
| #define | UART_WRITE_MSK (0x00) |
| #define | UART_SAVE (0x06) |
| #define | UART_READ (0x80) |
| #define | UART_STATUS_S (0x04) |
| #define | SOFT_VER (0x25) |
| #define | CONVERTER_ID (0x26) |
| #define | UART_DT_D2S (0x34) |
| #define | UART_DT_S2D_MAX (0x35) |
| #define | UART_DT_S2D_MIN (0x36) |
| #define | UART_CONST_I (0x37) |
| #define | UART_OFF_REG1 (0x38) |
| #define | UART_SLOPE_REG1 (0x39) |
| #define | UART_REG1_I (0x40) |
| #define | UART_OFF_REG2 (0x41) |
| #define | UART_SLOPE_REG2 (0x42) |
| #define | UART_REG2_I (0x43) |
| #define | UART_POWER (0x44) |
Serial communication payloads | |
Metering of output voltage. Metering of output current. Metering of input voltage. Metering of input current. Version of software. Converter identifier. NTC temperature. Die temperature. Buck-Boost mode operation. Communication blocks of 3 bytes. 1 byte command, 2 bytes payload. |----------—|----------—|----------—|----------—|----------—| 0x55 CMD DATA_0 DATA_1 CRC | |
| #define | UART_ON_OFF_START (0x8080) |
| #define | UART_ON_OFF_STOP (0x0101) |
| #define | UART_BOOST_MODE (0x8080) |
| #define | UART_BUCK_MODE (0x0101) |
| #define CONVERTER (5) |
Converter identification number. Totem-pole CCM PFC 3300W. [integer]
| #define CONVERTER_ID (0x26) |
Converter identifier.
| #define MASTER_KEY (1) |
Master key used for the storage of some default parameters first upload of the software.
| #define SOFT_VER (0x25) |
Version of software.
| #define SUB_VERSION (0) |
Main version number. [integer]
| #define UART_BOOST_MODE (0x8080) |
Buck-Boost mode selection. Boost mode payload.
| #define UART_BUCK_MODE (0x0101) |
Buck-Boost mode selection. Buck mode payload.
| #define UART_CONST_I (0x37) |
Current limit for maximum dead time.
| #define UART_DT_D2S (0x34) |
Dead time in diode to switch transition.
| #define UART_DT_S2D_MAX (0x35) |
Maximum dead time in switch to diode transition.
| #define UART_DT_S2D_MIN (0x36) |
Minimum dead time in switch to diode transition.
| #define UART_OFF_REG1 (0x38) |
Linear region 1 offset.
| #define UART_OFF_REG2 (0x41) |
Linear region 2 offset.
| #define UART_ON_OFF_START (0x8080) |
ON-OFF command. Start payload
| #define UART_ON_OFF_STOP (0x0101) |
ON_OFF command. Stop payload
| #define UART_POWER (0x44) |
Inverter power target.
| #define UART_READ (0x80) |
Can be combined with some commands for a read operation of a parameter.
| #define UART_REG1_I (0x40) |
Current limit for application of linear region 1.
| #define UART_REG2_I (0x43) |
Current limit for application of linear region 2.
| #define UART_SAVE (0x06) |
Saves parameters into flash. This takes large time.
| #define UART_SLOPE_REG1 (0x39) |
Linear region 1 slope.
| #define UART_SLOPE_REG2 (0x42) |
Linear region 2 slope.
| #define UART_STATUS_S (0x04) |
Read status. Status word
| #define UART_TRANSMIT_CLK_DIV (2) |
Clock divider for message transmission frequency.
| #define UART_WRITE_MSK (0x00) |
Can be combined with some commands for a write operation of a parameter.
| #define VERSION (1) |
Main version number. [integer]
| #define VERSION_BITS (8) |
Number of bits of subversion. [integer]
| #define XMC_FLASH_SECTOR_8 8 |
Address of the configurable parameters. Sector to be used during Flash access. Note: 256 bytes per page.
| void check_RAM_parameters | ( | ) |
Check that parameters in RAM are insight of a valid range.
Mostly useful after first run of the software, when all the parameters might be 0 after uploading the firmware. Dangerous situation. The ranges are quite wide and do not guarantee safe operation. Safe operation is up to the user.
|
inlinestatic |
Limit the value insight of the range between min and max.
| value | Value to be limited. |
| min | Minimum possible value. |
| max | Maximum possible value. |
Mostly useful after first run of the software, when all the parameters might be 0 after uploading the firmware, what could be dangerous situation.
| void load_ROM_parameters | ( | ) |
Copy parameters from ROM into an intermediate RAM area.
Due to the way Flash memory works, its required to have the parameters stored in an intermediate area. Writing into a Flash area involves as first step writing all the area with 0xFF. The program will access the data in RAM, what is faster.
|
inlinestatic |
UART execute received command and data.
Non blocking function. No interrupts involved. The command and the data are stored in a static buffer. The reception functions may have filled those buffers before calling this function.
|
inline |
UART receive data.
Non blocking function. No interrupts involved. Checks available data in the reception FIFO and execute command when a message is received. |----------—|----------—|----------—|----------—|----------—| 0x55 CMD DATA_0 DATA_1 CRC
|
inline |
UART transmit data.
Non blocking function. No interrupts involved. Update msg_cnt to 0, function will iterate over all possible output messages.
|
inlinestatic |
UART transmit data.
| command | Protocol command to be transmitted. |
| msg | Two byte payload of the message. |
Non blocking function. No interrupts involved. |----------—|----------—|----------—|----------—|----------—| 0x55 CMD DATA_0 DATA_1 CRC
|
static |
Selection of transmission data block. See uart_transmit function.
| const params_t parameters_DFLT |
Default parameters used until first storage by the user through the GUI.
| const params_t parameters_DFLT |
Default parameters used until first storage by the user through the GUI.
| params_t parameters_MAX |
Default maximum values for the stored parameters.
| params_t parameters_MAX_RAM |
Maximum values for the configurable parameters.
| params_t parameters_MIN |
Default minimum values for the stored parameters.
| params_t parameters_MIN_RAM |
Minimum values for the configurable parameters.
| params_t parameters_RAM |
Copy of the configurable parameters. To store modified parameters this intermediate storage is required (due to the behavior of FLASH memory during erase, copy procedures).
| params_t parameters_RAM |
Copy of the configurable parameters. To store modified parameters this intermediate storage is required (due to the behavior of FLASH memory during erase, copy procedures).
| const params_t* parameters_ROM = (params_t *)(XMC_FLASH_BASE + (XMC_FLASH_BYTES_PER_SECTOR * XMC_FLASH_SECTOR_8)) |
Address of the configurable parameters. To be used during Flash access. Note: 256 bytes per page.
| const params_t* parameters_ROM |
Address of the configurable parameters. To be used during Flash access. Note: 256 bytes per page.
|
static |
UART reception buffer