Skip to content

Commit 26c526f

Browse files
Sindre MidjaasSindre Midjaas
authored andcommitted
MPAE-18955: Readme and code updates from PR
1 parent 545737d commit 26c526f

File tree

4 files changed

+11
-17
lines changed
  • assignment1-led-toggle-application.X
  • assignment2-generate-pwm-measure-duty-cycle-and-frequency.X
  • assignment3-basis-of-a-binary-frequency-shift-keying-scheme.X

4 files changed

+11
-17
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The code in this repository is configured using MCC Melody for all three assignm
3434

3535
## Assignment 1: LED Toggle Application
3636

37-
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).
37+
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).
3838

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

@@ -174,12 +174,12 @@ Clock details:
174174

175175
### MCC Setup
176176

177-
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.
177+
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.
178178

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

181181
#### CCL
182-
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.
182+
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.
183183

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

204204
3. Open the project in MPLAB X IDE.
205205

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

208208
5. Build the solution and program the ATtiny817.
209209

assignment1-led-toggle-application.X/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ int main(void)
4444

4545
while(1)
4646
{
47+
/* While the active low SW0 is pressed, turn off the active low LED0 */
4748
if(!SW0_GetValue()) {
4849
LED0_SetHigh();
4950
while(!SW0_GetValue());

assignment2-generate-pwm-measure-duty-cycle-and-frequency.X/main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ void USART_send_data();
4949

5050
int main(void)
5151
{
52-
/* Initializes MCU, drivers and middleware */
5352
SYSTEM_Initialize();
5453
RTC_SetOVFIsrCallback(RTC_interrupt_handler);
5554
while (1) {
56-
if (TCB0.INTFLAGS) {
57-
TCB0.INTFLAGS = TCB_CAPT_bm;
58-
period_after_capture = TCB0.CNT;
59-
pulse_width_after_capture = TCB0.CCMP;
55+
if (TCB0_CaptureStatusGet()) {
56+
TCB0_CaptureStatusClear();
57+
period_after_capture = TCB0_CounterGet();
58+
pulse_width_after_capture = TCB0_PeriodGet();
6059
capture_duty = ((pulse_width_after_capture * 100) / period_after_capture);
6160
if (capture_duty > 100) {
6261
capture_duty = 0;
@@ -76,7 +75,7 @@ void RTC_interrupt_handler()
7675
if (change_duty_cycle > 100) {
7776
change_duty_cycle = 10;
7877
}
79-
TCA0.SINGLE.CMP0 = change_duty_cycle;
78+
TCA0_Compare0Set(change_duty_cycle);
8079
rtc_500ms_flg = 1;
8180
}
8281

assignment3-basis-of-a-binary-frequency-shift-keying-scheme.X/main.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
Main application
3939
*/
4040

41-
volatile uint16_t period_after_capture = 0;
42-
volatile uint16_t pulse_width_after_capture = 0;
43-
volatile uint8_t capture_duty = 0;
44-
volatile uint16_t capture_frequency = 0;
45-
46-
volatile bool rtc_500ms_flg = 0;
4741
volatile uint8_t change_duty_cycle = 10;
4842

4943
void RTC_interrupt_handler();
@@ -64,5 +58,5 @@ void RTC_interrupt_handler()
6458
if (change_duty_cycle > 100) {
6559
change_duty_cycle = 10;
6660
}
67-
TCA0.SINGLE.CMP0 = change_duty_cycle;
61+
TCA0_Compare0Set(change_duty_cycle);
6862
}

0 commit comments

Comments
 (0)