Skip to content

Commit

Permalink
MPAE-18955: Readme and code updates from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Sindre Midjaas authored and Sindre Midjaas committed Dec 12, 2024
1 parent 545737d commit 26c526f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The code in this repository is configured using MCC Melody for all three assignm

## Assignment 1: LED Toggle Application

An application will be developed to control the LED using the push-button on the board. The LED will be OFF while holding the button down(default state is LED ON).
An application will be developed to control the LED using the push-button on the board. The LED will be OFF while holding the button down (default state is LED ON).

On the ATtiny817 Xplained Pro board, LED0 is connected to pin PB4, and the push-button (SW0) is connected to pin PB5.

Expand Down Expand Up @@ -174,12 +174,12 @@ Clock details:

### MCC Setup

An overview of the MCC setup used in assignment 3 is shown in the image below. Remaining peripherals from assignment 2 can be deleted or just left as is. TCA0 is used with the same setup as assignment 2.
An overview of the MCC setup used in Assignment 3 is shown in the image below. Remaining peripherals from Assignment 2 can be deleted or just left as is. TCA0 is used with the same setup as Assignment 2.

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

#### CCL
In the CCL peripheral go the settings for LUT1. Enable LUT1 and enable LUT output. Set Input 0 Source to TCA0, Input 1 Source to Event1 and Input 2 Source to Event0. Set Gate Type to custom and enter in the truth table or set the OUT Result directly to 0xac.
In the CCL peripheral, go to the LUT1 settings. Enable LUT and Enable LUT output. Set Input 0 Source Selection to TCA0, Input 1 Source Selection to Event1 and Input 2 Source Selection to Event0. Set Gate Type to Custom and enter in the truth table or set the OUT result to 0xac.

<p><img src="images/assignment3_mcc_ccl_overview.jpg" width="600"/></p>
<p><img src="images/assignment3_mcc_ccl_lut1_1.jpg" width="600"/></p>
Expand All @@ -203,7 +203,7 @@ In the RTC peripheral, enable PIT Enable in the Periodic Interrupt Timer.

3. Open the project in MPLAB X IDE.

4. For Assignment 2 and 3 connect the female-to-female wire according to the Physical Setup.
4. For Assignment 2 and 3, connect the female-to-female wire according to the Physical Setup.

5. Build the solution and program the ATtiny817.

Expand Down
1 change: 1 addition & 0 deletions assignment1-led-toggle-application.X/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int main(void)

while(1)
{
/* While the active low SW0 is pressed, turn off the active low LED0 */
if(!SW0_GetValue()) {
LED0_SetHigh();
while(!SW0_GetValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ void USART_send_data();

int main(void)
{
/* Initializes MCU, drivers and middleware */
SYSTEM_Initialize();
RTC_SetOVFIsrCallback(RTC_interrupt_handler);
while (1) {
if (TCB0.INTFLAGS) {
TCB0.INTFLAGS = TCB_CAPT_bm;
period_after_capture = TCB0.CNT;
pulse_width_after_capture = TCB0.CCMP;
if (TCB0_CaptureStatusGet()) {
TCB0_CaptureStatusClear();
period_after_capture = TCB0_CounterGet();
pulse_width_after_capture = TCB0_PeriodGet();
capture_duty = ((pulse_width_after_capture * 100) / period_after_capture);
if (capture_duty > 100) {
capture_duty = 0;
Expand All @@ -76,7 +75,7 @@ void RTC_interrupt_handler()
if (change_duty_cycle > 100) {
change_duty_cycle = 10;
}
TCA0.SINGLE.CMP0 = change_duty_cycle;
TCA0_Compare0Set(change_duty_cycle);
rtc_500ms_flg = 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
Main application
*/

volatile uint16_t period_after_capture = 0;
volatile uint16_t pulse_width_after_capture = 0;
volatile uint8_t capture_duty = 0;
volatile uint16_t capture_frequency = 0;

volatile bool rtc_500ms_flg = 0;
volatile uint8_t change_duty_cycle = 10;

void RTC_interrupt_handler();
Expand All @@ -64,5 +58,5 @@ void RTC_interrupt_handler()
if (change_duty_cycle > 100) {
change_duty_cycle = 10;
}
TCA0.SINGLE.CMP0 = change_duty_cycle;
TCA0_Compare0Set(change_duty_cycle);
}

0 comments on commit 26c526f

Please sign in to comment.