1 / 13

Lab 4 – Servo Motor

Lab 4 – Servo Motor. Start Date: Week #6 Due date: Week #8. Overview of the timer system. See black book p. 66 TCNT Free running counter Prescaler sets relationship to ECLK (TMSK2) Main part of the timer subsystem Can be stopped while in wait or background debug mode (TSCR).

shino
Download Presentation

Lab 4 – Servo Motor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 4 – Servo Motor Start Date: Week #6 Due date: Week #8

  2. Overview of the timer system • See black book p. 66 • TCNT • Free running counter • Prescaler sets relationship to ECLK (TMSK2) • Main part of the timer subsystem • Can be stopped while in wait or background debug mode (TSCR)

  3. Input capture/output compare • TIC / TOC • Set using TIOS register • Input capture • When an event is detected on pin x, the value of TCNT is latched into the 16-bit register TCx • The input event (rising edge, falling edge, both, none) is set in a register (TCTL3 and TCTL4) • Flag is set in TFLG1 • Interrupt is generated if set in TMSK1

  4. Input capture/output compare • Output Compare • Successful output compare when the value in TCNT equals the value in TCx • Flag is set in TMSK1 • Output pin is changed according to action set in TCTL1 and TCTL2 • None, set, clear, toggle • Interrupt generated if set in TMSK1

  5. Overflow Interrupt • The system also has the ability to flag / generate an interrupt on TCNT overflow • Interrupt set from TMSK2 • Flag in TFLG2

  6. Registers • TIOS • Input capture / output compare • TCNT • Counter • TSCR • Enable, fast clear, wait and background mode • TMSK1 • interrupts

  7. Registers • TMSK2 • Prescalers • TFLG1 • Flags for the interrupts • Write a 1 to clear • TCx • This is where you write the values you are using for OC

  8. Servo Motor control • Period of ~21ms • Pulse width determines angle (from ~0.9 to ~2.1ms) • You will need to calibrate it

  9. LCD • There is test code on the web that you can use to test the LCD setup before you try to use it in your program • You may utilize the code to write your own program, but you need to make sure that you understand what the code is doing and why

  10. Interrupts on the HC12 • You will need to use interrupts if your main program is waiting for user input • D-Bug12 re-maps the interrupt vector table • Either use the D-Bug12 subroutine to set the vector, or set it yourself using the remapped locations (last slide) • More detailed information in the appendix

  11. Hints • The scope can be very helpful to check your output • If you don’t know how to use it, please ask • Check the LCD setup using the test code before you try to write to it

  12. Interrupt vectors

  13. Academic Misconduct • Reports and demos are submitted as a group, but it is a SINGLE group effort • You may talk with other groups but sharing code or reports is NOT ALLOWED • Copying code/reports from previous years is also NOT ALLOWED • If we find copying we are REQUIRED to report it

More Related