|
8 | 8 | </picture>
|
9 | 9 | </a>
|
10 | 10 |
|
11 |
| -# MTCH9010 Dynamic Enhanced Configuration Change Using the PIC18F56Q71 Microcontroller with MCC Melody |
| 11 | +# MTCH9010 Dynamic Enhanced Configuration Change Using the PIC18F56Q71 Microcontroller With MCC Melody |
12 | 12 |
|
13 | 13 | This MPLAB® X project shows how to dynamically change the configuration for MTCH9010 using the Enhanced Configuration mode. The PIC18F56Q71 microcontroller is used as a host device and the configuration is realized using the Universal Asynchronous Receiver Transmitter (UART) peripheral.
|
14 | 14 |
|
@@ -38,17 +38,17 @@ To program the Curiosity Nano board with this MPLAB X project, follow the steps
|
38 | 38 |
|
39 | 39 | ## Concept
|
40 | 40 |
|
41 |
| -In Enhanced Configuration mode, the MTCH9010 device can be configured using the UART communication protocol. To enter in this configuration mode, the following settings should be done on the MTCH9010 configuration pins: |
| 41 | +In Enhanced Configuration mode, the MTCH9010 device can be configured using the UART communication protocol. To enter in this configuration mode, the following settings must be done on the MTCH9010 configuration pins: |
42 | 42 | - The SYS_LK pin should be set to high (disabled)
|
43 | 43 | - The CFG_EN pin should be set to low (enabled)
|
44 | 44 |
|
45 | 45 | A Reset of the device is needed after the pins are configured to enter the configuration mode. This can be done using the RESET pin by making it low for a period of time (10 ms are used in this example) and then restore it to high.
|
46 | 46 |
|
47 |
| -After the Reset operation, the device will send the firmware version on the serial port and then wait for the configuration commands. Each command sent should be followed by a validation key (with the ASCII code equal to 0x0D in hexadecimal system). After a command is sent, the device will respond with ACK (Acknowledge, 0x06 in hexadecimal system) or NAK (Negative Acknowledge, 0x15 in hexadecimal system) followed by the validation key. If a NAK signal is received, the command must be sent again until it is validated by the device with an ACK signal. |
| 47 | +After the Reset operation, the device will send the firmware version on the serial port and then wait for the configuration commands. Each command sent will be followed by a validation key (with the ASCII code equal to 0x0D in hexadecimal system). After a command is sent, the device will respond with ACK (Acknowledge, 0x06 in hexadecimal system) or NAK (Negative Acknowledge, 0x15 in hexadecimal system) followed by the validation key. If a NAK signal is received, the command must be sent again until it is validated by the device with an ACK signal. |
48 | 48 |
|
49 |
| -In this code example, the `MTCH9010.h` and `MTCH9010.c` files contains the implementation of the functions used to configure the device in Enhanced Configuration mode. The `mtch9010_config_t` structure is used to simply define the parameters of the configuration that need to be sent. The `MTCH9010_Config(mtch9010_config_t configData)` function can be used to configure the device. This function sets the pins for configuration mode, reset the device and then send the configuration parameters using the UART1 peripheral. The function also implements a mechanism that verifies if each command is validated by the ACK signal. If it is validated, the program continues with the next command in the same way. If it is not validated, the program repeats the transmission. Each command is repeated for a maximum number of five times. After that the function returns an error code and the program blocks in an infinite loop. A message about the error code is also displayed on serial port using the UART2 peripheral. |
| 49 | +In this code example, the `MTCH9010.h` and `MTCH9010.c` files contains the implementation of the functions used to configure the device in Enhanced Configuration mode. The `mtch9010_config_t` structure is used to simply define the parameters of the configuration that need to be sent. The `MTCH9010_Config(mtch9010_config_t configData)` function can be used to configure the device. This function sets the pins for the configuration mode, resets the device and then sends the configuration parameters using the UART1 peripheral. The function also implements a mechanism that verifies if each command is validated by the ACK signal. If it is validated, the program continues with the next command in the same way. If it is not validated, the program repeats the transmission. Each command is repeated for a maximum number of five times. After that, the function returns an error code and the program blocks in an infinite loop. A message about the error code is also displayed on the serial port using the UART2 peripheral. |
50 | 50 |
|
51 |
| -This example contains two configurations of the MTCH9010. The user can switch between configurations using the on-board button of the PIC18F56Q71 Curiosity Nano. An Interrupt-on-Change (IOC) is generated on the negative edge of the button input. After the interrupt occurs, a debouncing mechanism is implemented using TMR0 peripheral. The button state is verified after a 20ms delay, triggered by the TMR0 overflow interrupt, to ensure that the pressed state is maintained. The parameters of the two configurations are shown below: |
| 51 | +This example contains two configurations of the MTCH9010. The user can switch between configurations using the on-board button of the PIC18F56Q71 Curiosity Nano. An Interrupt-on-Change (IOC) is generated on the negative edge of the button input. After the interrupt occurs, a debouncing mechanism is implemented using the TMR0 peripheral. The button state is verified after a 20 ms delay, triggered by the TMR0 overflow interrupt, to ensure that the pressed state is maintained. The parameters of the two configurations are shown below: |
52 | 52 | - Configuration 1:
|
53 | 53 | - SYS_LK: Enabled
|
54 | 54 | - CFG_EN: Disabled
|
@@ -109,7 +109,7 @@ The following peripheral and clock configurations are set up using the MPLAB Cod
|
109 | 109 | - Timer Enable: Disabled
|
110 | 110 | - Clock Source: LFINTOSC
|
111 | 111 | - Prescaler: 1:4
|
112 |
| - - Requested Period: 20ms |
| 112 | + - Requested Period: 20 ms |
113 | 113 | - TMR Interrupt Enable: Enabled
|
114 | 114 | <br><img src="images/mcc-tmr0.png" width="600">
|
115 | 115 |
|
|
0 commit comments