Professional Documents
Culture Documents
(Microcontroller):
TXD/ P3.1 11
INT0/ P3.2 12
INT1/ P3.3 14
T0/ P3.4 15
T1/ P3.5 16
WR/ P3.6 17
Clock pulses
(fixed time-interval)
Counter
Here size of the clock pulses doesn’t matter, only the no.
Of clock pulses counted matters
Register 1:
TMOD: Timer/Counter Mode Control register
Bit 7 6 5 4 3 2 1 0
Register2:
TCON: Timer/ Counter Control register
Bit 7 6 5 4 3 2 1 0
1— Timer1
0— Timer0
• When external timers/ counters are used, only then IE1 and IT1 are used
(i.e. when INT0 and INT1 are activated, as in case of inter-controller
communication)
Register3:
SCON: Serial Port Control register
Bit 7 6 5 4 3 2 1 0
Selection Sequence:
void main()
• The uC we use works on 5V
Current and Voltage rating: Current supplied by uC is 15 mA
Output voltage= 5V
Symbol of an LED
I
(Current sourcing) I
(Current sinking)
0
5V
• E.g.1
sbit LED = P1.3; //s— single
LED =0;
void main( )
{
P1.3= 0;
}
• E.g. 2
LED = 0;
delay ( );
LED = 1;
• void delay ( );
{
For (i=0; i<100; i++);
}
• 11.0592 MHz
|
1/12 divider (inside uC)
|
= 921.6 KHz (f)
|
1/f = 108.5 us (time-period of clock pulses)
void serial ( )
{
TMOD = OX20;
SCON = OX50;
TH = OXFD; // for 9600bps 11.0592MHz
TR1 = 1;
TI = 1; // printf turns TI 0
}
void main ( )
{
void serial ( );
printf (“SWARM”);
}
LENA LENB
(LENB)’
(LENA)’
RENA RENB
(RENB)’
(RENA)’
LENA/RENA LENB/REN
B
0 0
0 1
1 0
1 1
• 1 H-bridge = 2 movements
0, 0 stop
0, 1 CCW movement
1, 0 CW movement
1, 1 X