MC Interview Prep
MC Interview Prep
Protocols:
-> UART
-> SPI
-> I2C
-> CAN
d1 d2
UART
tx rx
->asynchronous
-> any duplex ( full duplex)
-> master - slave rx tx
frame format:
d1 d2 d3
rx tx tx
Mc -> Mc possible
18F -> 18F
D1 -> d2 -> d3
d1 d2
a
tx rx clcd
rx tx
SPI :
-> synchronous
-> full duplex
-> 1 master - multiple salve ( 1 M - 1S )
I2C
-> snchrounous
-> half duplex
-> multiple master - multiple salve ( 1 M - 1 S )
update address bit ( 10 bits )
M -> S
Master wait Ack ( 1 clock pulse )
1. M -> s ( unique ID & R/W )
2. M <- S (ack )
Data arbitration:
Mc 1 -> RTC ( 1111000) lowest unique ID
Mc 2 -> EEPROM(1010101)
overcome collision
lowest unique ID -> win the bus Mc 1 -> RTC ( 1111000) lowest data
Mc 2 -> RTC ( 1111000)
clock stretching:
int
after ACK :
Slave - pull the data line to low ( hold the clock )
clock synchronization:
overcome collision:
waiting for long(high wait state)
same frequency different frequency
Mc1( faster) 1 0 1 0
wired AND 1 1
Mc2 ( slower) 0 0 1 1
0 0 1
CAN
-> asynchronous
-> half duplex
-> multiple master - multiple slave ( 1M - M S )
message based protocol -> Message ID -> lowest message ID high priority
frame format:
-> standard frame ( 11 - bit )
-> extended frame ( 29 - bit )
standard frame:
types of frame:
count = T / (Q * R * P) time = 1 S
Q = 200 ns
count = 1 S / ( 200 ns * 256 * 1) R = 256 ticks
count = 1000000000 ns / ( 200 ns * 256 * 1) P=1
count = 19531.25
count => no.of overflow
4 bit mode ( D4 - D 7 )
MC
clcd
16 pins
MC
12 pins
Busy flag -> CLCd execute ( data / instruction ) -> poll for D7
-> to check CLCD has completed the execution of data / instrcution
D7 == 0 // completed
PWM :
brightness of led :
period = ton + toff
led ( 5v )
1. 5V - glow (full ) => PWM
2. 2.5 V - glow ( half )
3. 0v - off
Interrupt:
-> polling, disadvantage of polling. ( miss of event , bad responde time , bad power management )
->what is interrupt
-> types of interrupt
- hardware
- maskable
-external
-internal
- non maskable
-software
-> interrupt latency - delay
-> ways to handle the interrupt
- isr ( who will call isr ( MC ) , interrupt flag == 1 , who will set flag bit ( hardware))
- ivt
->what happens when an interrupt occurs
- pc ,satck