Académique Documents
Professionnel Documents
Culture Documents
NO:1
ARITHMETIC OPERATION
DATE:
AIM:
To write an assembly language program for performing arithmetic operation using 8051 micro
controller.
APPARATUS REQUIRED:
ALGORITHM:
ADDITION:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR ADDITION:
Start
Increment DPTR
Add A and B
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR ADDITION:
OUTPUT:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
SUBTRACTION:
ALGORITHM:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR SUBTRACTION:
Start
Increment DPTR
Subtract A and B
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR SUBTRACTION
OUTPUT:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
MULTIPLICATION:
ALGORITHM:
Step 2:Move the data from DPTR to accumulator and increment the address.
Step 4:Move the data from address to accumulator and increment the DPTR.
Step 5:Multiply the data from B register to accumulator and the result stored into the
Accumulator.
Step 6:Move the result in accumulator to corresponding value.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR MULTIPLICATION:
Start
Increment DPTR
Multiply A and B
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR MULTIPLICATION
OUTPUT:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
DIVISION:
ALGORITHM:
Step 2:Move the data from DPTR to accumulator and increment the address.
Step 4:Move the data from address to accumulator and increment the DPTR.
Step 5:Divide the data from B register to accumulator and the result stored into the
Accumulator.
Step 6:Move the result in accumulator to corresponding value.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR DIVISION:
Start
Increment DPTR
Divide A and B
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR DIVISION:
OUTPUT:
RESULT:
Thus the above program for Arithmetic Operations using 8051 Microcontroller was
successfully executed and Output was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:2
LOGICAL OPERATION
DATE:
AIM:
To write an assembly language program for performing logical operation using 8051 micro
controller.
AND OPERATION:
ALGORITHM:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR AND OPERATION:
Start
Initializing DPTR
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR AND OPERATION
OUTPUT:
INPUT 4500 10
OUTPUT 4501 00
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
OR OPERATION:
ALGORITHM
Step 1:Start the process by initializing the starting address.
Step 2:Move the data from DPTR to accumulator
Start
Initializing DPTR
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR OR OPERATION
OUTPUT:
INPUT
4500 10
OUTPUT 4501 30
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
X-OR OPERATION:
ALGORITHM:
Start
Initializing DPTR
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR X-OR OPERATION
OUTPUT:
INPUT 4500 10
OUTPUT 4501 30
RESULT:
Thus the above program for Logical Operations using 8051 Microcontroller was
successfully executed and Output was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:3
SQUARE& CUBE OF A NUMBER
DATE:
AIM:
To write an assembly language program to find square and cube of a number using 8051
micro controller.
APPARATUS REQUIRED:
• 8051microcontroller.
• Power supply
SQUARE OF A NUMBER
ALGORITHM:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR SQUARE OF A NUMBER:
Start
R to Acc
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
ADDRESS LABEL OPCODE MNEMONICS COMMENT
4100 90
4101 45 MOV DPTR,#4500 Move 4500 to DPTR
4102 00
MOVE THE CONTROL AT
4103 E0 MOVX A,@DPTR
DPTR TO A
4104 A3
INC DPTR INCREMENT DPTR
4105 F5
MOV B,A MOVE A TO B
4106 F0
4107
A4 MUL AB MULTIPLY A&B
OUTPUT
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
CUBE OF A NUMBER
ALGORITHM:
Start
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
Address Label Opcode Mnemonics comment
4100 90
4101 45 MOV DPTR,#4500 Move 4500 to DPTR
4102 00
MOVE THE CONTROL AT
4103 E0 MOVX A,@DPTR
DPTR TO A
4104 F5
MOV B,A Move A TO B
4105 F0
MUL AB MULTIPLY A AND B
4106 A4
4107 F8
MOV R0,A Move A TO R0
410A F0
MOV A,R0 MOVE R0 TO A
410B
E8 MUL AB MULTIPLY A AND B
410C
A4 INC DPTR INCREMENT DPTR
410D
A3 MOVE THE VALUE A TO
410E MOVE @DPTR,A
F0 DPTR
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
OUTPUT
RESULT
Thus the above program for square and cube of a number using 8051 was executed
successfully and output verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:4
1’s AND 2’s COMPLEMENT
DATE:
AIM:
To write an assembly language program to find 1’s and 2’s complement of a given
numbers by using 8051 microcontroller.
APPARTUS REQUIRED:
Start
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR 2’s COMPLEMENT
OUTPUT:
1’S COMPLEMENT
ALGORITHM:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOW CHART FOR 1’s COMPLEMENT:
Start
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
OUTPUT:
RESULT:
Thus the above program for 1’s and 2’s complement was successfully executed and
output verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:5
SORTING OF AN ARRAY
DATE:
AIM:
To write an assembly language program to find the largest and smallest number using
8051 microcontroller kit
APPARATUS REQUIRED:
• 8051microcontroller.
• Power supply
LARGEST NUMBER
ALGORITHM:
Step1:Start the program.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOW CHART FOR LARGEST NUMBER:
Start
Increment DPTR
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR LARGEST NUMBER
ADDRESS LABEL OP CODE MNEMONICS COMMENT
4100 90
4101 45 MOV DPTR,#5000 Move 5000 to DPTR
4102 50
4103 C3 CLR C Clear carry
4104 7a
MOV r2,#03h Move r2
4105 2q
MOV a content of
4106 E0 MOVX a,@ DPTR
DPTR
4107 F5 Move the content
MOV 30h,a
4108 30 From a to 30 l1
Increment DPTR
4109 A3 INC DPTR
Move the content
410a E0 MOVX a,@ DPTR
DPTR
410b 85
Compare Jumb not
410c 30 CJNE,30h
Equal to
410d FD
410e 04 SJMP NEXT Start jump & next
4110 F4
DN JC NEXT Jump if carry to next
4111 Fe
4112 F5
MOV 30h,a Move a to 30
4113 36
4114 DA Decrement jump
DJNI R1,up
4115 F3 Set to zero
4116 A3 INC DPTR Increment DPTR
4117 E5 Move the content of
MOV A,30h
4118 30 30h to A
4119 F0 MOVX @ DPTR ,a Move A to DPTR
411A 80
SJMP HERE Short jump here
411B FE
OUTPUT:
OPERATION ADDRESS DATA
5000 05
5001 FA
INPUT
5002 91
5003 B2
5004
OUTPUT FA
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
SMALLEST NUMBER
ALGORITHM:
Step1:Start the program.
Step2: Move the content fromDPTR to the location 5000.
Step 3: Move the content from DPTR accumulator,
Step4: Increment from DPTR.
Step5: Carry jump not equal to the accumulator.
Step6: Decrement jump not equal from register to the up.
Step7: Stop the process
Start
Increment DPTR
Prepared
Start by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR SMALLEST NUMBER
ADDRESS LABEL OP CODE MNEMONICS COMMENT
4100 90
4101 45 MOV DPTR,#5000 Move 5000 to DPTR
4102 50
4103 C3 CLR C Clear carry
4104 7a
MOV r2,#03h Move r2
4105 2q
MOV a content of
4106 E0 MOVX a,@ DPTR
DPTR
4107 F5 Move the content
MOV 30h,a
4108 30 From a to 30 l1
Increment DPTR
4109 A3 INC DPTR
Move the content
410a E0 MOVX a,@ DPTR
DPTR
410b 85
Compare Jumb Not
410c 30 CJNE,30h
Equal to
410d FD
410e 04 SJMP NEXT Start jump & next
4110 F4 Jump if carry is zero
DN JNC NEXT
4111 Fe next
4112 F5
MOV 30h,a Move a to 30
4113 36
4114 DA Decrement jump
DJNI R1,up
4115 F3 Set to zero
4116 A3 INC DPTR Increment DPTR
4117 E5 Move the content of
MOV A,30h
4118 30 30h to A
4119 F0 MOVX @ DPTR ,a Move A to DPTR
411A 80
SJMP HERE Short jump here
411B FE
OUTPUT:
OPERATION ADDRESS DATA
5000 05
5001 FA
INPUT
5002 91
5003 B2
OUTPUT 5004 05
RESULT:
Thus the above program for largest and smallest number was successfully executed and
the output was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX NO:6 SORTING
DATE :
AIM
To arrange the numbers in ascending order using 8051 micro controller kit.
APPARTUS REQUIRD
• 8051Microcontroller kit.
• Power supply
ASSENDING ORDER
ALGORITHM
Start
Prepared by
Mr. J. Stop
Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR ASSENDING ORDER
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
OUTPUT
DESCENDING ORDER
ALGORITHM
Step 1:Start the process
Step 2:Enter the input values to DPTR.
Step 3:Using 2 looping statements to arrange the input values to descending order.
Step 4:Stop the process.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOW CHART FOR DECENDING ORDER
Start
Stop
OUTPUT
Thus the above program for ascending order and descending order was executed
successfully and the output was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:7
MATRIX AND ADDITION AND SUBTRACTION
DATE:
AIM:
To write an assembly language program for matrix addition and subtraction using 8051
micro controller.
APPARATUS REQUIRED:
• 8051microcontroller.
• Power supply
MATRIX ADDITION
ALGORITHM:
Step2: Declare the value for the data pointer for higher and lower bit.
Step 3:Get the value in address 4500 and move to the accumulator,
Step5: Get the value in address 4600 and move the value to the accumulator.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOW CHART FOR MATRIX ADDITION:
Start
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR MATRIX ADDITION:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
OUTPUT
MATRIX SUBTRACTION
ALGORITHM:
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
Step1: start the program.
Step2: declare the value for the data pointer for higher and lower bit.
Step 3:get the value in address 4500 and move to the accumulator,
Step5: get the value in address 4600 and move the value to the accumulator.
Start
Stop
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR MATRIX SUBTRACTION:
RESULT:
Thus the above program for matrix addition and subtraction using 8051 microcontroller
was successfully executed and output was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX: NO: 8
AIM
APPARATUS REQUIRED
• Stepper motor
• 8051 microcontroller.
ALGORITHM
Step 4: Repeat the program till the counter value becomes zero
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
FLOWCHART FOR STEPPER MOTOR
START
INITIALIZE DPTR
INITIALIZE DELAY
YES
INCREMENT DPTR
NO
DECREMENT RO, LOOP
STOP
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR STEPPER MOTOR INTERFACE
LOOK UP TABEL
In order to increase the speed of motor delay has to be decreases and in order to decrease the
speed the delay has to be increased
RESULT
Thus the above program stepper motor interface control was successfully executed and
output verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX: NO: 9
DATE : BLINKING OF OF LED’s CONNECTED THROUGH PORTS
AIM
To develop a ‘C’ program to make the LED blink (including delay routine).Upon change
in the delay program the speed should vary.
APPARATUS REQUIRED
THEORY
LEDs are based on the semiconductor diode. When the diode is forward biased (switched
on), electrons are able to recombine with holes and energy is released in the form of light. This
effect is called electroluminescence and the color of the light is determined by the energy gap of
the semiconductor.
PROCEDURE
6. Type the below code and save it with the name (anyname.c)
7. Follow the steps 2 to 6 of Howto create a New Project to add the necessary file , compile
and built the program
8. Follow the procedures in How to Download a Code to Our Controller to download your
code
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR BLINKING LED
#include "stm32f4xx.h"
#include <stdio.h>
#include "stm32f4xx_rcc.h"
voidLED_init();
/* delay function */
longintb,c;
for(b=0;b<a;b++)
for(c=0;c<a;c++);
void main()
while(1)
delay(3000); //delay
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
GPIOD->ODR =0x00000000; //leds turns OFF
delay(3000); //delay
voidLED_init()
RESULT
The C-Language program to make the LED blink was developed and output was verified.
Upon change in the delay program the speed variation was verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:10
INTERFACING LED AND PWM
DATE:
AIM:
To write a C program to generate a PMW and to vary the brightness of the LED
depending on the duty cycle.
THEORY
The PMW is the based on the standard timer block and inherits all of its features. The
timer is designed to count cycles of the peripheral clock (PCLK) and optionally generate
interrupts or perform other actions when specified timer values occur, based on seven match
registers. The PWM function is also based on match register event
PROCEDURE
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM FOR LED AND PWM:
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
#include <stdio.h>
uint16_tPrescalerValue = 0;
staticintduty_cycle =1 ;
int duty;
/* Private function prototypes -----------------------------------------------*/
void TIM10_Config(void);
void TIM11_Config(void);
void TIM3_Config(void);
void delay(int delay);
intswitch_read();
voidmx_pinout_config(void);
void USART2_config();
/* main functions ---------------------------------------------------------*/
int main(void)
{
USART2_config();
TIM3_Config();
while(1)
{
duty = switch_read(); //receive switch value
/* for debug purpose */
// printf("\n duty =%d",duty);
/* Compute the prescaler value */
PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 21000000) - 1; //21MHZ timer/counter
clock
TIM3->ARR =0x348;//25khz
TIM3->PSC =PrescalerValue;
TIM3->CR1 = 0<<8|0<<9;
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
TIM3->CCMR1 = 1<<4|1<<5|1<<6;
TIM3->CCER |= 1<<0|1<<1; //enable capture/compare2
TIM3->CCR1 = duty; // apply duty cycle
TIM3->CCMR1 = 1<<3; //enable channel1 preload register
TIM3->CCMR1 = 1<<12|1<<13|1<<14;
TIM3->CCER |= 1<<4|1<<5; //enable capture/compare2
TIM3->CCR2 = duty; // apply duty cycle
TIM3->CCMR1 = 1<<11; //enable channel2 preload register
/* TIM10 enable counter */
TIM3->CR1 =1<<0;
}
}
void TIM3_Config(void)
{
RCC->APB1ENR |=1<<1;
RCC->AHB1ENR |=1<<2;
GPIOC->MODER |=0x0000A000;
GPIOC->AFR[0]|=0x22000000;
}
intswitch_read()
{
intval;
mx_pinout_config();
val = ((GPIOE->IDR)&0x14);
if(val == 0x04)
{
if(duty_cycle<= 0)
{
duty_cycle =1;
}
duty_cycle--; //variable decrement
delay(250);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
}
else if(val == 0x10)
{
duty_cycle++; //variable increment
delay(250);
if(duty >= 1500)
{
duty =1500;
}
}
return(duty_cycle);
}
intputchar(int data)
{
USART2->DR = (data & 0x01FF);
/* Loop until the end of transmission */
while((USART2->SR & 0x40) ==0)
{}
return data;
}
voidmx_pinout_config(void)
{
/*Enable or disable the AHB1 peripheral clock */
RCC->AHB1ENR |= 1<<3; // enable the clock to portD
RCC->AHB1ENR |= 1<<4; //enable clock to portE
GPIOE->MODER |=0x00000000; //set portE as i/p mode,other pins are input moode
GPIOE->OTYPER =0x00000000;
GPIOE->PUPDR = 0x00000000;
GPIOE->OSPEEDR =0xAAAAAAAA;
}
void USART2_config()
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
{
RCC->AHB1ENR |= 1 << 0; //clock to PORTA
RCC->APB1ENR |= 1 <<17; //clock to USART2
GPIOA->MODER |= 0x000000A0; //AF mode
GPIOA->AFR[0] |= 0x00007700; //USART2 AF
USART2->BRR = 0x16D;//115200 baud rate
USART2->CR3 = 0x0000;
USART2->CR2 = 0x000;
USART2->CR1 = 0x200C;
}
void delay(int delay)
{
int d1,d2;
for(d1=0;d1<delay;d1++)
for(d2=0;d2<delay;d2++);
}
2. Connect the +ve terminal of the LED board to the connector and – ve terminal to GND.
3. On varying the duty cycle of the PWM, the intensity of the LEDs will vary.
RESULT:
The C program to vary the intensity of the LED depending on the duty cycle of the PWM
has been developed and is verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX.NO:11
RELAY CONTROL
DATE:
AIM:
To write a C program to generate a relay signal and to vary the sound duration depending
on the duty cycle.
THEORY
The PMW is the based on the standard timer block and inherits all of its features. The
timer is designed to count cycles of the peripheral clock (PCLK) and optionally generate
interrupts or perform other actions when specified timer values occur, based on seven match
registers. The PWM function is also based on match register event
PROCEDURE
#include "stm32f4xx_usart.h"
#include "stm32f4xx_syscfg.h"
#include "stm32f4xx_gpio.h"
#include "misc.h"
#include <stdio.h>
inti,val;
uint32_ttmp;
void USART2_config()
NVIC_InitTypeDefNVIC_InitStructure;
GPIOA->MODER |= 0x000000A0;
GPIOA->AFR[0] |= 0x00007700;
USART2->CR3 = 0x0000;
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
USART2->CR2 = 0x000;
USART2->CR1 = 0x200C;
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure); }
void delay(int a)
inti,j;
for(i=0;i<a;i++)
for(j=0;j<a;j++);
voidbusy_check()
delay(200);
voidcommand_write(intcomm)
busy_check();
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
GPIOE->BSRRH = 0x0020; //low RS pin
GPIOE->ODR = (comm<<8)|(0<<5); //write the data from 8th bit.(i.E) PG8 to PG15
delay(200);
voidlcd_init()
command_write(0x38);
command_write(0x01);
command_write(0x0f);
command_write(0xC0);
command_write(0x06);
voidlcd_out(unsigned char a)
busy_check();
GPIOE->ODR = (a<<8)|(1<<5); //write the data from 8th bit.(i.E) PG8 to PG15
delay(200);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
GPIOE->BSRRH = 0x0080;//enable pin low
int i;
busy_check();
for(i=0;gk[i] !='\0';i++)
GPIOE->ODR =(gk[i]<<8)|(1<<5); //write the data from 8th bit.(i.E) PG8 to PG15
delay(200);
voidmx_pinout_config(void)
GPIOD->MODER |=0x00550055; //set port D0-D3 as o/p mode,other pins are input moode
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
GPIOD->OTYPER =0x00000000;
GPIOD->PUPDR = 0x00000000;
GPIOD->OSPEEDR =0xAAAAAAAA;
GPIOB->MODER = 0x55555555;
GPIOB->OSPEEDR = 0xFFFFFFFF;
GPIOE->OTYPER = 0x00000000;
GPIOE->PUPDR = 0x00000000;
GPIOE->OSPEEDR = 0xAAAAAAAA;
GPIOE->ODR = 0x00000000;
voidxbee_tx()
{
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("C");
USART2->DR = 0x43;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("D");
USART2->DR = 0x44;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("E");
USART2->DR = 0x45;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("F");
USART2->DR = 0x46;
}
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
/////////////////////////// 2 Row \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("8");
USART2->DR = 0x38;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
command_write(0xc8);
lcd_stringout("9");
USART2->DR = 0x39;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("A");
USART2->DR = 0x41;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
delay(4000);
command_write(0xc8);
lcd_stringout("B");
USART2->DR = 0x42;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000)
command_write(0xc8);
lcd_stringout("4");
USART2->DR = 0x34;
}
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
else if(val== 0xD0) //2nd column
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("5");
USART2->DR = 0x35;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("6");
USART2->DR = 0x36;
}
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
else if(val== 0x70) //4th column
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("7");
USART2->DR = 0x37;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
lcd_stringout("0");
USART2->DR = 0x30;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("1");
USART2->DR = 0x31;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
lcd_stringout("2");
USART2->DR = 0x32;
command_write(0x01);
command_write(0x80);
lcd_stringout("Xbee Transmit");
delay(4000);
command_write(0xc8);
lcd_stringout("3");
USART2->DR = 0x33;
void main()
USART2_config();
mx_pinout_config();
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
lcd_init(); //send initial commands
command_write(0x80);
lcd_stringout(d1);
command_write(0xC0);
lcd_stringout(d2);
delay(100);
lcd_stringout("Relay ON");
while(1)
xbee_tx();
GPIOD->ODR = 0x0<<8;
command_write(0x01);
command_write(0x80);
lcd_stringout("Relay ON");
delay(5000);
command_write(0x01);
command_write(0x80);
lcd_stringout("Relay OFF");
delay(5000);
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
}
2. Connect the +ve terminal of the LED board to the connector and – ve terminal to GND.
3. On varying the duty cycle of the PWM, the intensity of the LEDs will vary.
RESULT:
The C program to vary the intensity of the LED depending on the duty cycle of the PWM
has been developed and is verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
EX. NO: 12
AIM:
To develop a ‘C’ code to create a mailbox and to understand the RTOS functions.
THEORY:
Real time and embedded systems operate in constrained environments in which computer
memory and processing power are limited .They often need to provide their services within strict
time deadlines to their users and to the surrounding world.it is these memory ,speed and timing
constraints that dictate the use of real-time operating systems in embedded software.
Application
software
RTOS
HARDWARE
In providing this “abstraction layer” the RTOS kernel supplies five main categories of
basic services to application software.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
The most basic category of kernel services is Task management .This set of services
allows application software developers to design their software as a number of separate “chunks”
of software –each handling a distinct topic, a distinct goal, and perhaps its own real-time
deadline. Each separate “chunk” of software is called a “task”. The main RTOS service in this
category is the scheduling of tasks in the embedded system is in operation.
Since many embedded systems have stringent timing requirements. Most RTOS kernels
also provide acute basic Tuner services. Such a task delays and time-outs.
Many (but not all) RTOS kernels provide Dynamic Memory Allocation services. This
category of services allows tasks to borrow chunks of RAM memory for temporary use in
application software. Often these chunks of memory are then passed from task to task. As a
means of quickly communicating large amount of data between tasks. Some very small RTOS
kernels that are intended for tightly memory-limited environments, do not offer Dynamic
memory allocation.
May (but not all) RTOS kernels also provide a “Device I/0 Supervisor" category of services.
These services, “available provide a uniform framework for organizing and accessing the many
hardware device drivers that are typical often embedded system.
PROCEDURE
1. Follow the steps 1 of how to create a New project
2. Type the below code and save it with the name (any name. c)
3. Follow the steps 2-6 of how to create a new project to add the necessary file, compile
and build the program.
4. Follow the procedures in how to download a code to our controller to download your
code.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
PROGRAM
#include”ucos_ii.h”
#include”bsp.h”
OS_STK AppStk_send[TASK_STK_SIZE];
OS_STK_AppStk_recv[TASK_STK_SIZE];
Static voidbMailbox_App_Tx(void*p_arg);
Static voidbMailbox_App_Rx(void*p_arg);
OS_EVENT*pmailbox;
int main(void)
BSP_IntDisAll();
RCC_ClocksTypesDefrec_clocks;
RCC_GetClocksFreq(&rec_clocks);
SysTick_Config(rec_clocks.HCLK_Freuency/OS_TICKS_PER_SEC);
OSInit();/*ucosii initialization*/
OSTaskCreate(Mailbox_App_Tx,NULL,(OS_STK*)&AppStk_send[TASK_STK_SIZE-
1],(INT8U)10);/*sending task*/
OSTaskCreate(Mailbox_App_Rx,NULL,(OS_STK*)&AppStk_recv[TASK_STK_SIZE-
1],(INT8U)30);/*receiving task*/
OSStart();/*start os here*/
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
RETURN 0;
voidMailbox_App_Tx(void*p_arg)
INT8U i,err,*buffer[5];
buffer[0]=”1.RCC”;
buffer[1]=”2.DMA”;
buffer[2]=”3.NVIC”;
buffer[3]=”3.FPU”;
//buffer[4]=”5.FSMC”;
p_arg=p_arg;
pmailbox=OSMboxCreate(NULL);
for(i=0;i<5;)
{If((err=OSMbpxPost(pmailbox,buffer[i]))==NO_ERROR_GK)/*if success*/
Printf(“/n/r This is sender \n\t the mailbox has data, data is--> %s”,pmailbox->OSEventPtr);
OSTimeDlyHMSM(0,0,5,0);}
OSTimeDlyHMSM(0,0,5,0);
OSMboxDel(pmailbox,OS_DEL_NO_PEND,&err);
Void Mailbox_App_Rx(void*p_arg)
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
{
INTU8 err;
INT16U timeout=100;
INT8U *buffer;
p_arg = p_arg;
for(;;)
Buffer = OSMboxPend(pmailbox,timeout,&err);
Else
Break;
OSTimeDlyHMSM(0,0,6,0);}}
RESULT
The c-language program to create a mailbox and to understand about the RTOS functions
is developed and is verified.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
VIVA QUESTIONS & ANSWERS
12. What are the points to be considered while connecting power supply rails with embedded
system?
• A processor may have more than two pins of Vdd and Vss
• Supply should separately power the external I/O driving ports, timers, and clock
• From the supply there should be separate interconnections for pairs of Vdd and Vss pins analog
ground analog reference and analog input voltage lines.
14. What are the two essential units of a processor on a embedded system?
• Program Flow control Unit
• Execution Unit
15. What does the execution unit of a processor in an embedded system do?
The EU includes the ALU and also the circuits that execute instructions for a program control task. The
EU has circuits that implement the instructions pertaining to data transfer operations and data conversion
from one form to another.
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
17. Define microprocessor.
A microprocessor is a single VLSI chip that has a CPU and may also have some other units for example
floating point processing arithmetic unit pipelining and super scaling units for faster processing of
instruction.
25. What are the typical characteristics of an embedded system? Typical characteristics:
Perform a single or tightly knit set of functions; Increasingly high-performance & real-time
constrained; Power, cost and reliability are often important attributes That influence design;
Application specific processor design can be a significant component of some embedded systems.
Other characteristics:
• Application specific
• Digital signal processing in ECS
• Reactive
• Real-time
• Distributed
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
26. What are the advantages and disadvantages of embedded system?
Advantages: Customization yields lower area, power, cost.
Disadvantages: Higher HW/software development overhead design, compilers, debuggers, etc., may
result in delayed time to market.
27. What are the applications of an embedded system? Embedded Systems: Applications:
• Consumer electronics, e.g., cameras, camcorders, etc.,
• Consumer products, e.g., washers, microwave ovens, etc.,
• Automobiles (anti-lock braking, engine control, etc.,)
• Industrial process controllers & avionics/defense applications
• Computer/Communication products, e.g., printers, FAX machines, etc.,
• Emerging multimedia applications & consumer electronics
31. What are the main components of an embedded system? Three main components of
embedded systems:
1. The Hardware
2. Application Software
3. RTOS
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET
33. Explain digital signal processing in embedded system continued digitization of signals
increasing the role of DSP in ES.
• Signals are represented digitally as sequence of "samples"
• ADC’s are moving closer to signals
35. What are the two essential units of a processor on an embedded system?
a. Program flow control unit (CU)
b. Execution unit (EU)
36. What does the execution unit of a processor in an embedded system do?
The execution unit implements data transfer and data conversion. It includes ALU and
circuits that execute instruction for jump, interrupt, etc.,
39. When is Application Specific System processors (ASSPs) used in an embedded system?
An ASSP is dedicated to real-time video processing applications such as video conferencing,
video compression and decompression systems. It is used as an additional processing unit for
running application specific tasks in the place of processing using embeddedsoftware.
44. What are the various embedded system requirements Types of requirements imposed by
embedded applications:
Functional requirements
Temporal requirements
Dependability requirements
Prepared by
Mr. J. Satheesh Kumar,
AP / ECE / HICET