Skip to content

Commit

Permalink
MPAE-18615: Add AC DACREF clarification and update formula formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Moe Arnesen authored and Henrik Moe Arnesen committed Nov 27, 2024
1 parent 187ff3d commit b4b0081
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ All communication is sent over the data interface for this basic Virtual Serial
This example is configured to run on 24 MHz. The minimum oscillator frequency for USB on the AVR DU is 12 MHz.
<p><img src="images/mcc_clock_control.jpg" width="500"/></p>

The application uses a delay function to blink an LED if the USB connection fails. This delay function is dependent on knowing the main clock speed through the F_CPU define. Here, this has been set up as a preprocessed define macro in the project settings, as seen in the image below.
The application uses a delay function to blink an LED if the USB connection fails. This delay function is dependent on knowing the main clock speed through the F_CPU define. Here, this has been set up as a preprocessed define macro in the project settings.

<p><img src="images/mplab_macros.jpg" width="500"/></p>

Alternatively, it could have been added in the main file as `#define F_CPU 24000000UL` above the `#include <util/delay.h>` line.

### USB Voltage Detection Setup
To ensure that the USB peripheral only tries to attach to the bus when the Curiosity Nano is connected to the PC, the Analog Comparator will periodically check if the voltage is within the acceptable range for V<sub>BUS</sub>.
To ensure that the USB peripheral only tries to attach to the bus when the Curiosity Nano is connected to the PC, the Analog Comparator will be checked periodically if the voltage is within the acceptable range for V<sub>BUS</sub>.

#### Voltage Reference Setup
In the V<sub>REF</sub> peripheral, the Voltage Reference is set to 2.048V.
Expand All @@ -86,11 +86,11 @@ The positive input is set to the USB DETECT pin on the Curiosity Nano which is c

To calculate the DACREF, use the formula from the data sheet:

*V_DACREF = (DACREF / 256) * V_REF*
*V<sub>DACREF</sub>> = (DACREF / 256) * V<sub>REF</sub>*

Due to the voltage divider present on the Curiosity Nano, a threshold of 0.32V is needed for this project. Inputting this value into the Requested Voltage field in MCC can calculate the DACREF value automatically.

Refer to the [AVR64DU32 Curiosity Nano User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/AVR64DU32-Curiosity-Nano-UserGuide-DS50003671.pdf) for more information on how the *USB DETECT* is implemented on the Curiosity Nano.
Refer to the [AVR64DU32 Curiosity Nano User Guide](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/UserGuides/AVR64DU32-Curiosity-Nano-UserGuide-DS50003671.pdf) for more information on how the USB DETECT is implemented on the Curiosity Nano.

<p><img src="images/mcc_ac_hardware_settings.jpg" width="500"/></p>

Expand All @@ -102,22 +102,22 @@ The RTC is configured to run on a 1 kHz clock with no prescaler.
<p><img src="images/mcc_rtc_hardware_settings.jpg" width="500"/></p>

#### RTC Interrupt Settings
The PIT is then set to trigger at every 32 clock cycles of the RTC clock. this gives an update rate of ~31 Hz.
The PIT is then set to trigger at every 32 clock cycles of the RTC clock, which gives an update rate of ~31 Hz.
<p><img src="images/mcc_rtc_interrupt_settings.jpg" width="500"/></p>

The application is set up to need five stable voltage readings before initiating the USB communication. This means that, with no voltage fluctuations and the settings above, the start-up time will be in the 0.16s range.
The application is set up to need five stable voltage readings before initiating the USB communication. Considering the previous settings and an environment with no voltage fluctuations, the start-up time is in the 0.16s range.

### LED Setup
The on-board LED of the Curiosity Nano is used to indicate if the USB communications has failed. The LED is connected to the PF1 pin and can be selected as an output in the Pin Grid View below.

<p><img src="images/mcc_pin_grid.jpg" width="600"/></p>

The pin is given a custom name in the Pins menu, as seen below. This makes the code easier to read with function generated using this name.
The pin is given a custom name in the Pins menu, as seen below. This makes the code easier to read with the functions generated using this name.

<p><img src="images/mcc_pin_naming.jpg" width="600"/></p>

### Global Interrupts
Since this example uses interrupts for voltage monitoring, global interrupt must be enabled in the Interrupt Manager.
Since this example uses interrupts both for voltage monitoring and for USART communication, toggle the Global Interrupt Enable button Interrupt Manager.

<p><img src="images/mcc_interrupt.jpg" width="500"/></p>

Expand Down

0 comments on commit b4b0081

Please sign in to comment.