100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
prelab 5 University of Michigan EECS 461 $7.99   Add to cart

Exam (elaborations)

prelab 5 University of Michigan EECS 461

  • Course
  • Institution

EECS 461 Prelab 5 Due 02/18/2020 1. T_clock = 1/40e6 = 2.5e-8 s For 20 kHz, T_interrupt = 1/20e3 s = 5e-5s ⇒ # LPIT clocks = 5e-5/2.5e-8 = 2000 ⇒ timer initial value (TMR_VAL) = 2000 - 1 = 1999 For 1 kHz, T_interrupt = 1/1e3 kHz = 1e-3s ⇒ # LPIT clocks = 1e-3/2.5e-8 = 40000 ⇒ ti...

[Show more]

Preview 2 out of 5  pages

  • February 13, 2023
  • 5
  • 2022/2023
  • Exam (elaborations)
  • Questions & answers
avatar-seller
EECS 461
Prelab 5
Due 02/18/2020

1.
T_clock = 1/40e6 = 2.5e-8 s

For 20 kHz,
T_interrupt = 1/20e3 s = 5e-5s
⇒ ​# LPIT clocks​ = 5e-5/2.5e-8 = ​2000
⇒ timer initial value (TMR_VAL) = 2000 - 1 = ​1999

For 1 kHz,
T_interrupt = 1/1e3 kHz = 1e-3s
⇒ ​# LPIT clocks​ = 1e-3/2.5e-8 = ​40000
⇒ timer initial value (TMR_VAL) = 40000- 1 = ​39999

/*
LPIT.h
University of Michigan
EECS 461, Embedded Control Systems
Low Power Interrupt Timer (LPIT)
Read Chapter 30 in S32K144 User's Manual

Revision History:
2017-11-16 schmo
2017-03-13 Paul Domanico
*/

#include "LPIT.h"

/* Array of 4 interrupt service routines. One for each channel */
static int LPIT_IRQn[4] = LPIT_IRQS;/* fill in */

void enableLPIT(){
/* 29.6.5 PCC LPIT Register */
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_CGC(0b0); /* fill in */; /* Disable PCC
LPIT clock to change PCS */
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_PCS(110); /* fill in */; /* Clock
source: SPLL2_DIV2_CLK */
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_CGC(0b1); /* fill in */; /* Enable
clk to LPIT0 regs */

/* 46.4.1.4.2 Module Control Register */

, LPIT0->MCR = LPIT_MCR_M_CEN(0b1)/* fill in */; /* enable module clk
(allows writing other LPIT0 regs)*/
}



void initLPIT(const uint8_t channel, const uint32_t frequency, const isr_t
handler, const uint32_t priority) {
/* 46.4.1.9.3 Timer Value Register */
LPIT0->TMR[channel].TVAL = TMR_VAL/* fill in */; /* channel timer start
value */

/* 46.4.1.6.2 Module Interrupt Enable Register */
LPIT0->MIER = 1 << channel; /* fill in */; /* Timer Interrupt Enabled for
Channel */

/* 46.4.1.9.3 Timer Control Register */
LPIT0->TMR[channel].TCTRL = /* fill in */; /* T_EN : Timer channel is
disabled to set registers*/
LPIT0->TMR[channel].TCTRL = LPIT_TMR_TCTRL_MODE(0)/* fill in */; /* MODE :
32 periodic counter mode */
LPIT0->TMR[channel].TCTRL = LPIT_TMR_TCTRL_TSOT(0)/* fill in */; /* TSOT :
Timer decrements immediately based on restart */
LPIT0->TMR[channel].TCTRL = LPIT_TMR_TCTRL_TSOI(0)/* fill in */; /* TSOI :
Timer does not stop after timeout */
LPIT0->TMR[channel].TCTRL = LPIT_TMR_TCTRL_TROT(0)/* fill in */; /* TROT :
ignore external trigger */

/* 46.4.1.7.3 Set Timer Enable Register */
LPIT0->SETTEN = 1 << channel/* fill in */; /*SET_T_EN_n : enable timer
for channel */

/* defined in interrupt_manager.c */
INT_SYS_InstallHandler(LPIT_IRQn[channel], handler, (isr_t*) 0);
INT_SYS_SetPriority(LPIT_IRQn[channel], priority);
INT_SYS_EnableIRQ(LPIT_IRQn[channel]);
}



void clearFlagLPIT(const uint8_t channel){
/* 46.4.1.5.3 Module Status Register */
LPIT0->MSR = 1 << channel;/* fill in */; /* clear TIFn */
}

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller ExamsConnoisseur. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78310 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.99
  • (0)
  Add to cart