Presentation is loading. Please wait.

Presentation is loading. Please wait.

Example 11 Analog-to-Digital Converter Lecture L5.1.

Similar presentations


Presentation on theme: "Example 11 Analog-to-Digital Converter Lecture L5.1."— Presentation transcript:

1 Example 11 Analog-to-Digital Converter Lecture L5.1

2 miniDragon+ Serial cable Reset button Power plug2 pushbutton switches A/D Pot Run/Load switch 7-segment display I/O headers Keypad header LCD Header

3 A/D Ports MC9S12DP256

4 ATD0 Pins PADD0 – PADD7 (ch# 0 – 7) Pins 67,69,71,73, 75,77,79,81 ATD1 Pins PAD8 – PAD15 (ch# 0 – 7) Pins 68,70,72,74, 76,78,80,82

5 ATD0 Pins PADD0 – PADD7 (ch# 0 – 7) Pins 67,69,71,73, 75,77,79,81 ATD1 Pins PAD8 – PAD15 (ch# 0 – 7) Pins 68,70,72,74, 76,78,80,82 Pot

6 Method of Successive Approximation

7

8

9 // Example 11: A/D Converter -- Pot #include /* common defines and macros */ #include /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" int val; void main(void) { PLL_init();// set system clock frequency to 24 MHz ad0_enable(); // enable a/d converter 0 lcd_init(); // enable lcd while(1) { val = ad0conv(7); // read pot on channel 7 val = val >> 1;// shift 1 bit right (divide by 2) set_lcd_addr(0x40); // display on 2nd row of LCD write_int_lcd(val);// write value in field of 5 ms_delay(100);// delay 0.1 seconds } Example 11


Download ppt "Example 11 Analog-to-Digital Converter Lecture L5.1."

Similar presentations


Ads by Google