Documente Academic
Documente Profesional
Documente Cultură
4. Microcontrollers
http://en.wikipedia.org/wiki/Microcontroller
http://www.engr.sjsu.edu/bjfurman/courses/ME106/ME106pdf/MicroC_overview.pdf
http://www.mikroe.com/eng/chapters/view/64/chapter-1-introduction-to-microcontrollers/
http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
http://www.codeproject.com/Articles/29528/Programming-the-PIC-Microcontroller-in-C-using-PIC
http://www.mikroe.com/eng/chapters/view/4/chapter-3-i-o-ports/
http://www.mikroe.com/eng/chapters/view/2/chapter-1-pic16f887-microcontroller-device-overview/
Op Amps
Sensors & Transducers
Electronic Instrumentation Systems
Microcontrollers
4.0 Microcontrollers
1.
2.
3.
4.
5.
6.
Introduction to Microcontrollers
Components of A Microcontroller
Microcomputer Architecture
Binary and Hexadecimal Numbers
Basic DSP Operations
Programming Microcontrollers
3.
4.
5.
10
11
12
i8051 microarchitecture
13
14
15
16
17
19
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000);
// waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000);
// waits for a second
}
21
TRISB = %00000000
TRISB = %11111111
PORTB = %11111111
PORTB.0[i] = 1
->
->
->
->
A.
B.
C.
D.
24
ANSEL register :
determine whether the pins will act as analog inputs or digital inputs/outputs.
RA0 = AN0 (determined by bit ANS0 of the ANSEL register);
RA1 = AN1 (determined by bit ANS1 of the ANSEL register);
RA2 = AN2 (determined by bit ANS2 of the ANSEL register);
RA3 = AN3 (determined by bit ANS3 of the ANSEL register);
25
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
#include <htc.h>
#include <pic.h>
#include <delay.c>
int j;
// general global variables
void Wait_These_Seconds(float s) {
// only to 3 decimals
int milli_Equiv;
// milli second equivalent integer
milli_Equiv=1000*s;
for(j=1; j<=milli_Equiv; j++) { DelayMs(1); }
}
main() {
TRISB=0xF0;
// RB4:RB7 are input ; 11110000 in binary
for(;;) {
if(RB7==1) {
RB0=1;
// LED ON
Wait_These_Seconds(1.8);
// delay for 1.8 seconds
RB0=0;
// LED OFF
Wait_These_Seconds(0.9);
}
if(RB7==0) {
// interrupt is connecting RB7 to ground
RB0=1;
// LED ON
Wait_These_Seconds(0.7);
// delay for 0.7 seconds
RB0=0;
// LED OFF
Wait_These_Seconds(0.1);
}
}
}
26