Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Week 11 - intro to C

No description

Paul Mesarcik

on 14 May 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Week 11 - intro to C

//introduction to C
//week 11
//loose ends
feed watch dog:
//loose ends 2
if(PTDD&0x01) //not pressed
else // pressed
//loose ends 3
while ((ATDSC & 0x80) == 0);
used to accurately run periodic events
when counter value reaches modulo:
counter reset
TOF (timer overflow) is set
interrupt can be caused
//setting up timers
decide on origin of clock pulse
setup TMPxSC (including prescaler)

decide of modulo value (both bytes)
set up interrupt
//modulo and prescaler
1. Decide, in seconds, how long your delay must be.
2. Assume bus frequency of 20Mz.
3. The cycle length will be the reciprocal of the bus frequency.
4. Divide the delay length by the cycle length to calculate the number of cycles needed.
5. Divide the number of cycles by 65536 (2^16)
If the result is bigger than 128 then your time delay is too long and you will need
multiple timer periods. The rounded up number is your prescaler value.
6. Divide the number of cycles by the prescaler value. The result is the modulo value.

//timer calculations
cycleLength = 1/F = 50ns
cyclesNeeded = delay/cycleLength
generate a delay of 0.1s
= 0.1/50x10^-9
= 2 000 000
prescaler = cyclesNeeded/65536
= 30.51
prescaler = 32
modulo = cyclesNeeded/prescaler
modulo = 62500
62500 = 0xF424
TPMxMOD = 0xF424;
Full transcript