CS计算机代考程序代写 DT131C Embedded Systems Programming

DT131C Embedded Systems Programming
Tutorial 5
Dawit Mengistu (dawit.mengistu@hkr.se)

ATMega 168 μC Pin Diagram
2

Digitial I/O
• Writeabinary0tooutputpin6,1tootherpinsof port D.
• Set on port D, set the 4 left most bits as input, the 4 right most bits for output, and write 12 decimal on the output.
• Read the input from the rightmost 2 pins of Port B, with the last pin connected to an internal pull up resistor, and write the result to the left most bits of PORTB.
3

Exercise
• The two pins of port B in the previous examples read engine temperature and speed levels (high and low) and store the readings in memory:
pin1 reads temperature every 15sec; pin2 reads speed every 10 sec.
(Use the delay function (defined in avr/delay.h) if needed) void delaytime(uint16_t t) {
for (int i=0;i