8051 PIC AVR Arduino Reneasas Peripherals

Thursday, 28 May 2020

Interview Questions and Answers for Embedded Software Engineer -1


1.       What is difference between RS232 and RS485?

Ans. RS232 is full duplex and RS485 is half duplex. RS232 has RX,TX and GND lines and RS485 has D+ and D- lines for communication. RS232 is used for short distance(15m) and RS485 is used for long distance(1200m). Voltage levels for RS232 is +3V to +15V(logic 0) and -3V to -15V(logic 1).Voltage levels for RS485 is -7V to +12V(difference in two signals is greater than 0.2V then logic1 otherwise logic 0).


2.       What is difference between I2C and SPI ?

Ans.  I2C is two wire protocol(SDA and SCL). SPI is 4 wire protocol (SS,MISO,MOSI,SCK).I2C is half duplex and SPI is full duplex.I2C supports Clock Stretching and SPI does not.Clock stretching is used to slow down speed by holding SCL low.I2C is multimaster communication while SPI is not.I2C is slower(100kbps,400kbps and 3.4Mbps) and SPI is faster(10Mbps). I2C requires more power and SPI requires less power.I2C uses addressing mechanism and SPI uses chip select mechanism.

3.       What does static keyword used for?

Ans. Static variables have property of preserving their value after they are out of their scope.They is initialized only once and exist till termination of program. Static variables are allocated memory in data segment not in stack segment. Static variables should not declared inside structure. The reason is C Compiler required entire structure elements to be placed together because memory allocation for structure should be contiguous.

4.       What does volatile is in C?

Ans.  Volatile is qualifier used for omitting variable from optimization.It tells compiler that variable may change at any time during execution.

5.       What are storage classes in C and explain?

Ans. Auto, Static, Extern, register.


MQTT implementation using GSM module


A]AT commands for MQTT broker connection
1)AT:Used to check the interaction between the computer and the module. This command is usually replied with an OK if the port and the module can connect correctly, else wise it comes back with a result code ERROR.
2)AT+CIPMODE: Used for selecting TCPIP application mode. '0' non-transparent mode and '1' is transparent mode. In this mode we don’t need to type CIPSEND again and again to send the packet
3)AT+CSTT: Sets up the apn, user name and password for the PDP (Packet Data Protocol) context.
4)AT+CIICR: This command brings up the GPRS or CSD call depending on the configuration previously set by the AT+CSTT command.
5)AT+CIFSR: The command returns the local IP address. It is imperative the the PDP context must have been activated before to get the IP address.
6)AT+CIPSTART: Starts a TCP or UDP connection.
7)AT+CIPSHUT: Will close the GPRS PDP context.

STEPS:
1] AT
2] AT+CIPMODE=1
3] AT+CSTT=” WWW”,””,””
4] AT+CIICR
5] AT+CIFSR
6] AT+CIPSTART="TCP","m13.cloudmqtt.com","13494"
7] AT+CIPSHUT
B]MQTT packet formation:
Packet structure is given is excel sheet.
·         Abbreviations:

1)CONN=Connect packet
2)PUB=Publish packet
3)SUB=Subscriber packet
4)RL=Remaining length
5)PLEN=Protocol length
6)LVL=Level
7)FL=Flag length
8)CIDLEN=Client ID length
9)ULEN=Username length