3.1 Atmel | START Project Creation
Todo: Create a
new Atmel | START Project, where CLOCK, ADC, and USART modules are
configured.
- Open Atmel Studio 7.
- Create a new Atmel | START project in Atmel Studio by
- Open the CREATE NEW PROJECT window by selecting File->New->Atmel START project.
- Select the target hardware by entering 817X in the Filter on device... text box and selecting ATtiny817 Xplained Pro from the list.
- Create the project by clicking CREATE NEW PROJECT as shown in Figure 3-1.
Info: The MY SOFTWARE COMPONENTS window should appear. - Rename the project by clicking MY
PROJECT in the MY SOFTWARE COMPONENTS window and select Rename
Component as shown in Figure 3-2. Enter the project name, for example, ADC_Training, in the popped up RENAME COMPONENT window and click Rename to close it.Note: This step is optional to rename the project name.
- Add ADC and USART drivers to the project
by
- Open the ADD SOFTWARE COMPONENTS window by clicking
- Expand Drivers by clicking +
- Select ADC and USART by clicking
, as shown in Figure 3-3Info: ADC and USART will be highlighted as the selected modules as shown in Figure 3-3.
- Add the drivers to the project by clicking the Add component(s) button.
- Open the CLOCK CONFIGURATOR window
by clicking on the navigation tab at the left side of the window as shown in Figure 3-4.
- Configure the Main Clock (CLK_MAIN) clock
source by
- Open the CLOCK SETTINGS window by clicking as shown in Figure 3-4.
- Select 20 MHz as the Main Clock Source from the drop-down menu.
- Select 4 as the Prescaler division from the drop-down menu.
- Close CLOCK SETTINGS by
clicking the Close button.Info: For this application, 20 MHz OSC is chosen as the main clock source with prescaler division equal to 4. The resulting CPU clock frequency is 5 MHz.
For quick reference, clicking
next to each configuration will provide the data sheet description of individual bit settings.
- Return to MY SOFTWARE COMPONENTS, by clicking in the navigation tab on the top of the left side of the window.
- Configure the ADC module by following the steps in Figure 3-6:
- Open the configuration menu for ADC, by clicking ADC_0.
- Select Drivers:ADC:Window as Driver from the drop-down menu.
- Select PB1 as analog input AIN/10 from the SIGNALS menu.
- Ensure all interrupt handlers end up in driver_isr.c for this training, by un-checking Include harness for IRQ on conversion...
- Enable the Result Ready Interrupt, by selecting the RESRDY:Result Ready Interrupt Enable checkbox.
- Ensure the ADC runs when the device is in Standby Sleep mode, which will be used in the next assignment.
- Ensure the ADC is enabled after initialization, by selecting ENABLE:ADC Enable.
- Select 8-bit mode as the RESSEL:ADC Resolution.
- Configure the ADC clock to 625 KHz, by selecting CLK_PER dividend by 8 from the PRESC:Clock Prescaler drop-down menu. The main clock runs at 5 MHz, which gives ADC clock at 625 KHz.
- Select VDD as Reference Selection from the drop-down menu.
- Select ADC input pin 10 in the MUXPOS: Analog Channel Selection Bits field to select the analog input AIN/10 connected to the ADC.
- Configure the USART module by following
the steps in Figure 3-7:
- Open the USART configuration menu, by clicking USART_0.
- Select Driver:USART:Basic as Driver from the drop-down menu.
- Select PB2 as the USART output by selecting it from the TXD drop-down menu.
- Ensure the output is enabled upon
initialization, by selecting TXEN:Transmitter Enable.Info: The device will only send data over USART, so the RXEN:Receiver Enable can remain unchecked.
- Configure a high baud rate in order
to ensure fast USART data transfer, by setting the Baud Rate to
96000.Info: Transferring the USART data fast will enable the device to spend more time in Sleep mode, which will reduce the current consumption. The Sleep mode will be used in the following assignment.
- Generate the project by clicking .
- Select the desired path where the project should be stored as shown in Figure 3-8 as an example and click OK.
Result: An Atmel | START project, featuring an ADC and USART driver, has been created in
Atmel Studio.