IoT Processors Record
IoT Processors Record
Record Notebook
Course Code & Title : CEC369& IoT Processors
Year / Sem : III / V
Academic Year : 2024 – 2025 (ODD)
Regulation : R 2021
Register Number :
KNOWLEDGE INSTITUTE OF TECHNOLOGY, SALEM
Department of Electrical and Electronics Engineering
Vision, Mission, PEOs, PSOs, POs and CO
Vision
• To produce technically competent Electrical and Electronics Engineers
having world class skills with ethical and social values
Mission
• To provide state-of-the art facilities in Electrical and Electronics Engineering
for improving the learning environment and research activities
• To continuously enrich the knowledge and skill of students towards the
employment and creation of innovative products for society
• To develop ethical, social-valued and entrepreneurship skilled Electrical and
Electronics Engineers
ADMIN 2
PO-2 Problem analysis: Identify, formulate, review research literature, and
analyze complex engineering problems reaching substantiated
conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
PO-3 Design/development of solutions: Design solutions for complex
engineering problems and design system components or processes that
meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental
considerations.
PO-4 Conduct investigations of complex problems: Use research-based
knowledge and research methods including design of experiments,
analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
PO-5 Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the
limitations.
PO-6 The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering
practice.
PO-7 Environment and sustainability: Understand the impact of the
professional engineering solutions in societal and environmental contexts,
and demonstrate the knowledge of, and need for sustainable
development.
PO-8 Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO-9 Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams and in multidisciplinary settings.
ADMIN 3
Course Outcomes:
At the end of the course, the student should have the
Explain the architecture and features of ARM.
List the concepts of exception handling.
Write a program using ARM CORTEX M3/M4.
Learn the architecture of STM32L15XXX ARM CORTEX M3/M4.
Design an SoC for any application
ADMIN 4
CONTENTS
Marks
S.No Date Name of the Experiments Page No Faculty Sign
Awarded
ARM Assembly Programming
ADMIN 5
PROGRAM :
ADDRESS MNEMONICS
LABEL OPCODE COMMENTS
(Hex) (Hex)
Tabulation:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
ADMIN 6
EX NO :01
DATE :
ARM ASSEMBLY PROGRAM TO ADD TWO NUMBERS
AIM:
To write a program to add two 32-bit numbers stored in R0 and R1 registers and write the result to R2.
APPARATUS REQUIRED
PROCEDURE:
1. Set a breakpoint at the line where the ADD instruction is located. This is where r2 will get the result
of r0 + r1.
3. When the program hits the breakpoint, verify the values of r0, r1, and r2:
5. Verify that the memory location RESULT contains the sum of the two numbers.
ADMIN 7
ADMIN 8
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 9
PROGRAM : (ARM Assembly with UDIV Instruction )
ADDRESS MNEMONICS
LABEL OPCODE COMMENTS
(Hex) (Hex)
ADDRESS MNEMONICS
LABEL OPCODE COMMENTS
(Hex) (Hex)
ADMIN 10
EX NO : 02
DATE :
ARM ASSEMBLY TO DIVISION TWO NUMBERS
AIM:
Write ARM assembly to perform the function of division. Registers r1 and r2 contain the dividend
and divisor, r3 contains the quotient, and r5 contains the remainder.
PROCEDURE:
ARM Assembly with UDIV Instruction
UDIV r3, r1, r2:
UDIV performs an unsigned integer division of r1 by r2 and stores the quotient in r3.
Example: If r1 = 10 and r2 = 3, then r3 will contain 3.
MLS r5, r3, r2, r1:
MLS (Multiply and Subtract) calculates the remainder.
It multiplies r3 (the quotient) by r2 (the divisor) and subtracts the result from r1 (the dividend).
This stores the remainder in r5.
Example: r5 = 10 - (3 * 3) = 1.
ADMIN 11
Flowchart : (ARM Assembly with UDIV Instruction )
Tabulation:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
Tabulation:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
ADMIN 12
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 13
Program: Turn On Green and Blue LEDs on STM32LDiscovery
#include<stm32f405xx.h>
int main(void)
,
RCC -> AHB1ENR |= (1<<3); //DUE TO PORT D
GPIOD -> MODER &= ~(3 << 24);
GPIOD -> MODER |= (1 << 24); //SETTING THE PIN PD12 GREEN LIGHT
GPIOD -> MODER &= ~(3 << 30);
GPIOD -> MODER |= (1 << 30); // SETTING THE PIN PD15 BLUE LIGHT
STM IDE
ADMIN 14
EX NO: 03
DATE :
PROGRAM TO TURN ON LED USING ON STM32
AIM:
Write a program to turn on green LED (Port B.6) and Blue LED (Port B.7) on STM32L Discovery
by configuring GPIO.
APPARATUS REQUIRED
PROCEDURE:
ADMIN 15
Blue Led glowing
Hardware Output
ADMIN 16
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 17
Program: Transmit a string using on Stm32
void usart2_init(void);
void usart2_write(char ch);
void usart2_write_string(const char *str);
void led_init(void);
void led_on(void);
void led_blink(void);
int main(void) ,
// Initialize USART2 and LED
usart2_init();
led_init();
while (1) ,
// Infinite loop to keep the PD12 LED on
-
-
void usart2_init(void) ,
// Enable clock for GPIOA, GPIOD, and USART2
RCC->AHB1ENR |= (1 << 0); // Enable GPIOA clock (for USART2 TX)
RCC->AHB1ENR |= (1 << 3); // Enable GPIOD clock (for LEDs)
RCC->APB1ENR |= (1 << 17); // Enable USART2 clock
// Configure USART2
USART2->BRR = 0x0683; // Set baud rate to 9600 (assuming 16 MHz clock)
USART2->CR1 |= (1 << 3); // Enable transmitter
USART2->CR1 |= (1 << 13); // Enable USART2
-
ADMIN 18
EX NO: 04
DATE :
PROGRAM TO TRANSMIT A STRING ON STM32 USING USART2
AIM:
Transmit a string “Programming with ARM Cortex” to PC by configuring the registers of USART2.
Use polling method.
APPARATUS REQUIRED
PROCEDURE:
Enable Necessary Clocks
Enable the clocks for GPIOA, USART2, and GPIOD by configuring the RCC->AHB1ENR and RCC-
>APB1ENR registers.
Configure PA2 as USART2 TX
Set PA2 to alternate function mode in GPIOA->MODER and assign AF7 (USART2) in GPIOA->AFR*0+.
Initialize USART2
Set the baud rate to 9600 bps using USART2->BRR.
Enable the transmitter (USART2->CR1 |= (1 << 3)) and turn on USART2 (USART2->CR1 |= (1 << 13)).
Set Up LEDs
Configure PD12 (green LED) and PD13 (orange LED) as output by setting their mode in GPIOD-
>MODER.
Write Function for USART2 Transmission
Implement a function (usart2_write) to send a single character. Wait until the transmit buffer is
empty (TXE set), then write the character to USART2->DR.
Write Function to Transmit Strings
Create a function (usart2_write_string) to iterate over a string and transmit each character using
usart2_write. Call the LED blink function after transmitting each character.
Blink PD13 During Transmission
Write a function (led_blink) to toggle PD13 on and off with a short delay for visible blinking.
Turn on PD12 After Transmission
Implement a function (led_on) to set the output data register for PD12, turning it on to indicate the
transmission is complete.
Write the Main Function
Initialize USART2 and LEDs using usart2_init() and led_init().
Transmit the string "Programming with ARM Cortex" using usart2_write_string.
Call led_on() to turn on PD12 after the transmission.
Compile, Flash, and Test
Compile the program, flash it onto the STM32F407 board, and connect the board to a terminal
application via a USB-to-serial adapter.
Verify:
o PD13 blinks during string transmission.
o PD12 remains lit after the transmission complete
ADMIN 19
led_blink(); // Blink LED during transmission
-
-
STM IDE
ADMIN 20
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 21
PROGRAM: Toggle the Led using on Stm32
#include <stm32f405xx.h>
void ms_delay_tim2(uint32_t n)
,
RCC -> APB1ENR |= (1<<0); // ENABLE THE BUS (174), timer 2 is in 0th position
TIM2 -> PSC = 16000-1;// Prescaler value , THAT (-1) indicates that the 0 to 15999 (642)
TIM2 -> ARR = 1000-1;// total speed is 16MHZ , ((16MHZ/16000))=1000.same (-1) indicates from 0 to
999(642)
TIM2 -> CR1 |= (1<<0);//enable the timer(627), timer 2 in 0th position
for(uint32_t i=0 ; i<n ; i++)
,
while(!(TIM2 -> SR & (1<<0))); //WHEN BOTH 1 IT TERMINATES
TIM2 -> SR &=~ (1<<0);
-
-
int main(void)
,
RCC -> AHB1ENR |= (1<<3);
GPIOD -> MODER &=~ (3 << 24);
GPIOD -> MODER |= (1<<24);//GREEN LIGHT PD12
GPIOD -> MODER &= ~(3 << 30);
GPIOD -> MODER |= (1 << 30);// SETTING THE PIN PD15 BLUE LIGHT
GPIOD -> MODER &= ~(3 << 28);
GPIOD -> MODER |= (1 << 28);// SETTING THE PIN PD14 RED LIGHT
GPIOD -> MODER &= ~(3 << 26);
GPIOD -> MODER |= (1 << 26);// SETTING THE PIN PD15 ORANGE LIGHT
while(1)
,
GPIOD -> ODR ^=(1<<12);//^ for toggle
GPIOD -> ODR ^=(1<<13);
GPIOD -> ODR ^=(1<<14);
GPIOD -> ODR ^=(1<<15);
ms_delay_tim2(1);//n=10
-
-
ADMIN 22
EX NO : 05
DATE :
PROGRAM TO TOGGLE THE LED USING ON STM32
AIM:
Write a program to toggle the LEDs at the rate of 1 sec using standard peripheral library. Use Timer3
for Delay.
APPARATUS REQUIRED
PROCEDURE:
ADMIN 23
STM IDE
LED STATUS
ADMIN 24
Includes and GPIO Configuration:
Include stm32l1xx.h for STM32L series (adjust the header file if using a different series).
GPIO_Config() sets PB6 and PB7 as output pins for the green and blue LEDs.
Timer3 Configuration:
Configures the prescaler (TIM3->PSC) to divide the 16 MHz clock by 16,000, resulting in a 1 kHz clock
(1 ms tick).
Checks the update interrupt flag (TIM3->SR & TIM_SR_UIF) to ensure the interrupt is triggered by the
timer update.
Toggles the LED states using GPIOB->ODR ^= (1 << 6) for the green LED and GPIOB->ODR ^= (1 << 7)
for the blue LED.
Main Loop:
The while(1) loop is empty because the LED toggling is managed by the Timer3 interrupt.
ADMIN 25
PROGRAM: Transmit a string using on Stm32
#include <stm32f405xx.h>
#include <string.h>
void USART3_init(void);
void USART3_write(uint8_t ch);
void USART3_write_string(const char* str);
void delayMs(int);
void LED_init(void);
void LED_on_red(void);
void LED_off_red(void);
void LED_on_orange(void);
void LED_off_orange(void);
int main(void)
,
USART3_init(); /* Initialize USART3 */
LED_init(); /* Initialize LEDs */
while (1)
,
// Main loop can do other tasks
delayMs(1000); // Delay to avoid busy looping
-
-
void USART3_init(void)
,
RCC->AHB1ENR |= (1 << 2); // Enable GPIOC clock
RCC->APB1ENR |= (1 << 18); // Enable USART3 clock
// USART3 settings
USART3->BRR = 0x0683; // 9600 baud rate at 16MHz
USART3->CR1 |= (0xC << 0); // Enable RE and TE bits
ADMIN 26
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 27
USART3->CR1 |= (1 << 6); // Enable RX
USART3->CR2 = 0; // 1 stop bit
USART3->CR3 = 0; // Default settings
USART3->CR1 |= (1 << 13); // Enable USART3
-
void USART3_write(uint8_t ch)
,
// Write the character to USART data register
USART3->DR = ch;
while (!(USART3->SR & (1 << 7))); // Wait until TXE is set
-
void USART3_write_string(const char* str)
,
while (*str) // Transmit until null terminator
,
USART3_write(*str++); // Send each character
-
-
void LED_init(void)
,
RCC->AHB1ENR |= (1 << 3); // Enable GPIOD clock
// Configure PD14 (Red LED) as output
GPIOD->MODER &= ~(3 << 28); // Clear mode for PD14
GPIOD->MODER |= (1 << 28); // Set PD14 to output mode
// Configure PD13 (Orange LED) as output
GPIOD->MODER &= ~(3 << 26); // Clear mode for PD13
GPIOD->MODER |= (1 << 26); // Set PD13 to output mode
-
void LED_on_red(void)
,
GPIOD->ODR |= (1 << 14); // Set PD14 high to turn on red LED
void LED_off_red(void)
,
GPIOD->ODR &= ~(1 << 14); // Set PD14 low to turn off red LED
-
void LED_on_orange(void)
,
GPIOD->ODR |= (1 << 13); // Set PD13 high to turn on orange LED
-
void LED_off_orange(void)
,
GPIOD->ODR &= ((1 << 13)); // Set PD13 low to turn off orange LED
-
void delayMs(int n)
,
int i;
for (; n > 0; n--)
for (i = 0; i < 2000; i++); // Simple delay loop
-
-
ADMIN 28
EX NO : 06
DATE :
PROGRAM TRANSMIT A STRING ON STM32 USING USART3
AIM:
Transmit a string “Programming with ARM Cortex” to PC by using standard peripheral library with the help
of USART3. Use polling method.
APPARATUS REQUIRED
PROCEDURE:
ADMIN 29
ADMIN 30
RESULT:
Mark Split Up
Observation / 08
Record / 02
Total / 10
Faculty Signature
ADMIN 31