F1 Merged
F1 Merged
F1 Merged
Submitted to
Department of Electronics
Cochin University of Science and Technology
Kochi – 682022, Kerala
OCTOBER 2023
1
DECLARATION
I hereby declare that the entire work embodied in this laboratory report has been
carried out by me and no part of it has been submitted for any degree or diploma
of any institution previously.
Place: Kochi
Date:20-10-2023 ARJUN K
2
ACKNOWLEDGEMENT
I would like to express my deepest appreciation to all those who provided me the
possibility to complete this report.
A special gratitude to our guide and faculty in charge, Smt. Sandhya Venugopal,
whose contribution in stimulating suggestions and encouragement, helped me to
co-ordinate the lab and project works and for the valuable guidance in writing this
report.
Finally, I would also like to express a special thanks to my batchmates, for helping
me out at different points of lab experiments and mini project.
ARJUN K
3
TABLE OF CONTENTS
9
PRIME NUMBERS
LAB CYCLE NO: 1
FAMILIARIZATION OF PIC16F877A BOARD.
INTERFACE LED AND SWITCH WITH PIC16F877A
FAMILIARIZATION OF PIC16F877A
All PIC microcontroller family uses Harvard architecture. This architecture has the
program and data accessed from separate memories so the device has a program
memory bus and a data memory bus (more than 8 lines in a normal bus). This improves
the bandwidth (data throughput) over traditional von Neumann architecture where
program and data are fetched from the same memory (accesses over the same bus).
Separating program and data memory further allows instructionsto be sized differently
than the 8-bit wide data word.Now we will move to PIC16F877A.
The 16F877A is a capable microcontroller that can do many tasks because it hasa
large enough programming memory (large in terms of sensor and control projects) of 8k
words and 368 Bytes of RAM.
PIC16F877A has 40 pins by 33 paths of I/O. The 40 pins make it easier to use the
peripherals as the functions are spread out over the pins. This makes it easier to decide
what external devices to attach without worrying too much if there are enough pins to do
the job.
The pinout of the 16F877A is:
• Lead-free; RoHS-compliant
• Operating speed: 20 MHz, 200 ns instruction cycle
• Operating voltage: 4.0-5.5V
• Industrial temperature range (-40° to +85°C)
• 15 Interrupt Sources
• 35 single-word instructions
• All single-cycle instructions except for program branches (two-cycle)
Special Microcontroller Features
Peripheral Features
Analog Features
Aim: Design and write a program to blink a LED with switch using microcontroller
PIC16F877A.
Theory: In this project, we interface a led and switch with PIC16F877A microcontroller.
The PIC microcontroller PIC16F877A is one of the most popular microcontrollers in the
industry. It has a total number of 40 pins and among which 33 pins are general-purpose
input-output pins. PIC16f877A has 40 pins among which 33 are general-purpose
input-output pins. The input/output pins are integrated as 5 ports, PORTA, PORTB,
PORTC, PORTD, PORTE. These ports are used for input /output operations by the
microcontroller. There will be a data direction register (TRIS) and a port register (PORT)
corresponding to each port in the microcontroller. TRIS register is used for configuring
the port as input or output and the value in the port register will be the state of the pins
of the corresponding port.
The figure is a schematic of interfacing a LED with the microcontroller. The anode of
LED is connected to the microcontroller and cathode is connected to ground through a
resistor. When the voltage at the microcontroller pin is high the LED will be turned ON
and when the voltage is low the LED will be turned off. In this project we have
connected RB0 of PIC16F877A to the resistor and RC0 to the switch/button. The
program is designed in such a way that when button is pressed LED will blink
continuously till when it released.
Procedure:
#include <xc.h>
#define _XTAL_FREQ 8000000
#define sw RC0
#define led RB0
void main()
{
TRISB=0x00; // port b as output
TRISC=0x01; //port c as input
while(1)
{
if(sw==1) // if switch is pressed
{
led=1;
while(sw==1); // till switch is released
}
led=0;
}
}
Simulation Result:
Result:
In this project, a LED and switch is successfully interfaced with PIC16F877A
microcontroller and implemented a program for a led to blink when switch is pressed.
LAB CYCLE NO: 2
Interface a 16x2 LCD to PIC16F877A microcontroller &
display a Malayalam word & a English word
Aim: Interface a 16x2 LCD to PIC16F877A microcontroller and display a Malayalam and a
English word.
Theory: In this project, we interface a 16x2 alphanumeric LCD display with PIC16F877A
microcontroller. The pin diagram is shown;
Here VDD is LCDs power supply pin, VSS is ground pin. VEE can be connected to a
potentiometer to vary the contrast of the display. RS can be used as a data register for RS=1,
and an instruction register to input LCD commands for RS=0. RW is read/write command, LCD
is set to write the input on to display for RW=0 and read the input for RW=1. Now enable pin set
to unsure that this data is displayed on LCD. That is E=1 enables input into LCD and E=0 stalls
the input into LCD. D0-D7 are data input pins. We can either run the LCD in 4 bit 9mode or in 8
bit mode. We in this project runs it in 8 bit mode, that all the pinsfrom D0-D7 are used as inputs.
In this project we are required to display a Malayalam word and a English word which means
we need to display a custom character because an LCD do not support Malayalam characters if
not for custom character design. So, in order to do this custom character design we need to
make use of CGRAM memory of LCD display. This is a memory which can be modified by user.
So that we can store custom characters in this memory and thereby display it. This memory can
store up to 8 user defined characters.
CGRAM:
To define a custom character in CGRAM we must access their CGRAM address location. The
command for access CGRAM address is show on picture below.
0x40 is the first address of CGRAM. Every 1 custom character needs 8 CGRAM locations,
because the dot format of LCD is 5×8. Every 1 CGRAM location can store 1 row of 5×8 dot
format. So, for the first custom character pattern will be stored from address 0x40 to 0x47. After
we write some pattern to CGRAM location, the CGRAM pointer is increased automatically. Once
the custom characters are stored, we need to use the command 0X80 and then display the
characters from CGRAM location using a display command that we define.
LCD Commands: these are the different LCD commands, We can input these commands to
LCD when RS=0, that is when it is used as an instruction register.
Procedure:
1. Design the circuit shown Figure1.3, components used are PIC16F877A microcontroller, LED,
resistor, switch.
2. Code the program in MPLAB in .c and build the program code.
3. Get the hex file path and load it to PIC16F877A in our circuit in proteus software.
4. Run the simulation and obtain the required results.
Fig 1.3
Program Code:
#define _XTAL_FREQ 20000000
#define RS RD2
#define EN RD3
#define D4 RD4
#define D5 RD5
#define D6 RD6
#define D7 RD7
#include <xc.h>
if(data_bit& 2)
D5 = 1;
else
D5 = 0;
if(data_bit& 4)
D6 = 1;
else
D6 = 0;
if(data_bit& 8)
D7 = 1;
else
D7 = 0;
}
void Lcd_Cmd(char a)
{
RS = 0;
Lcd_SetBit(a); //Incoming Hex value
EN = 1;
__delay_ms(4);
EN = 0;
}
Lcd_Clear()
{
Lcd_Cmd(0); //Clear the LCD
Lcd_Cmd(1); //Move the curser to first position
}
void Lcd_Start()
{
Lcd_SetBit(0x00);
for(int i=1065244; i<=0; i--) NOP();
Lcd_Cmd(0x03);
__delay_ms(5);
Lcd_Cmd(0x03);
__delay_ms(11);
Lcd_Cmd(0x03);
Lcd_Cmd(0x02); //02H is used for Return home -> Clears the RAM and initializes the
LCD
Lcd_Cmd(0x02); //02H is used for Return home -> Clears the RAM and initializes the
LCD
Lcd_Cmd(0x08); //Select Row 1
Lcd_Cmd(0x00); //Clear Row 1 Display
Lcd_Cmd(0x0C); //Select Row 2
Lcd_Cmd(0x00); //Clear Row 2 Display
Lcd_Cmd(0x06);
}
int main()
{
unsigned int a;char i;
TRISD = 0x00;
Lcd_Start();
while(1)
{
Lcd_Clear();
//Print all Custom characters//
Lcd_Set_Cursor(1,1);
Lcd_Print_Char(0); // Display Custom Character 0
Lcd_Print_Char(1); // Display Custom Character 1
Lcd_Print_Char(2); // Display Custom Character 2
Lcd_Print_Char(3); // Display Custom Character 3
Lcd_Print_Char(4);
Lcd_Print_Char(5); // Display Custom Character 4
Lcd_Print_Char(6); // Display Custom Character 5
Lcd_Print_Char(7); // Display Custom Character 6
Lcd_Set_Cursor(2,1);
Lcd_Print_String(" I am Arjun"); //binary value of alpha from data-sheet
__delay_ms(1000);
}
return 0;
}
Simulation Result:
Result:
In this project, a 16x2 LCD is successfully interfaced with PIC16F877A microcontroller and
implemented a program for to display a Malayalam and a English word.
LAB CYCLE NO: 3
Generation of PWM signal using PIC16F877A
Duty Cycle: The term duty cycle describes the proportion of 'on' time to the
regular interval or 'period' of time; a low duty cycle corresponds to low power,
because the power is off for most of the time. Duty cycle is expressed in percent,
100% being fully on. When a digital signal is on half of the time and off the other
half of the time, the digital signal has a duty cycle of 50% and resembles a
"square" wave. When a digital signal spends more time in the on state than the
off state, it has a duty cycle of >50%. When a digital signal spends more time in
the off state than the on state, it has a duty cycle of <50%. Here is a pictorial that
illustrates these three scenarios:
Procedure:
1. Design the circuit shown below, components used are PIC16F877A microcontroller,
LED, resistor, switch.
2. Code the program in MPLAB in .c and build the program code.
3. Get the hex file path and load it to PIC16F877A in our circuit in proteus software.
4. Run the simulation and obtain the required results.
Program Code:
// PIC16F877A Configuration Bit Settings
// 'C' source line config statements
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = ON // Low-Voltage (Single-Supply) In-Circuit Serial
Programming Enable bit (RB3/PGM pin has PGM function; low-voltage
programming enabled)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit
(Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits
(Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit
(Code protection off)
#include <xc.h>
#define _XTAL_FREQ 20000000
#define TMR2PRESCALE 4
#include <xc.h>
long PWM_freq = 5000;
PWM_Initialize()
{
PR2 = (_XTAL_FREQ/(PWM_freq*4*TMR2PRESCALE)) - 1;
//Setting the PR2 formulae using Datasheet Makes the PWM work in 5KHZ
CCP1M3 = 1;
CCP1M2 = 1; //Configure the CCP1 module
T2CKPS0 = 1;T2CKPS1 = 0; TMR2ON = 1; //Configure the Timer module
TRISC2 = 0; // make port pin on C as output
}
PWM_Duty(unsigned int duty)
{
if(duty<1023)
{
duty = ((float)duty/1023)*(_XTAL_FREQ/(PWM_freq*TMR2PRESCALE));
// On reducing //duty = (((float)duty/1023)*(1/PWM_freq)) / ((1/_XTAL_FREQ) *
TMR2PRESCALE);
CCP1X = duty & 1; //Store the 1st bit
CCP1Y = duty & 2; //Store the 0th bit
CCPR1L = duty>>2;// Store the remining 8 bit
}
}
void ADC_Initialize()
{
ADCON0 = 0b01000001; //ADC ON and Fosc/16 is selected
ADCON1 = 0b11000000; // Internal reference voltage is selected
}
unsigned int ADC_Read(unsigned char channel)
{
ADCON0 &= 0x11000101; //Clearing the Channel Selection Bits
ADCON0 |= channel<<3; //Setting the required Bits
__delay_ms(2); //Acquisition time to charge hold capacitor
GO_nDONE = 1; //Initializes A/D Conversion
while(GO_nDONE); //Wait for A/D Conversion to complete
return ((ADRESH<<8)+ADRESL); //Returns Result
}
void main()
{
int adc_value;
TRISC = 0x00; //PORTC as output
TRISA = 0xFF; //PORTA as input
TRISD = 0x00;
ADC_Initialize(); //Initializes ADC Module
PWM_Initialize(); //This sets the PWM frequency of PWM1
do
{
adc_value = ADC_Read(4); //Reading Analog Channel 0
PWM_Duty(adc_value);
__delay_ms(50);
}while(1); //Infinite Loop
}
Simulation Result:
Result:
PWM signal is successfully generated using PIC16F877A microcontroller.
EXPERIMENT 4
INTERFACE A KEYPAD TO PIC16F877A
1, 2, 3, 4 columns are set to 1 at a time in a loop and the output from its
rows are checked. That is if 1=1, then rows A, B, C, D are checked for an
output of 1. If 17 it's all zero, no key is pressed. If any of the rows give an
output 1, the corresponding key pressed is displayed on the LCD. For
example, If 1 = 1, D=1 implies key ‘*’ is pressed. This way the program
continuously scans for a key press and displays a successful find of the key
press.
Procedure:
1. Design the circuit shown below, components used are PIC16F877A
microcontroller, LCD, Keypad.
2. Code the program in MPLAB in .c and build the program code.
3. Get the hex file path and load it to PIC16F877A in our circuit in proteus
software.
4. Run the simulation and obtain the required results.
Program Code:
#include <pic.h>
__CONFIG( FOSC_HS & WDTE_OFF & PWRTE_OFF & CP_OFF & BOREN_ON &
LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF);
#define rs RD2
#define en RD3
#define R1 RB0
#define R2 RB1
#define R3 RB2
#define R4 RB3
#define C1 RB4
#define C2 RB5
#define C3 RB6
#define C4 RB7
void lcd_init();
void cmd(unsigned char a);
void dat(unsigned char b);
void show(unsigned char *s);
void lcd_delay();
void main()
{
unsigned int i;
TRISD=0;
lcd_init();
keyinit();
unsigned char b;
cmd(0x80);
show(" Enter the Key ");
while(1)
{
cmd(0xc7);
b=key();
dat(b);
}
}
void lcd_init()
{
cmd(0x02);
cmd(0x28);
cmd(0x0e);
cmd(0x06);
cmd(0x80);
}
void lcd_delay()
{
unsigned int lcd_delay;
for(lcd_delay=0;lcd_delay<=1000;lcd_delay++);
}
void keyinit()
{
TRISB=0XF0;
OPTION_REG&=0X7F; //ENABLE PULL UP
}
Simulation Result:
Result:
Interfaced a keypad to PIC16F8771 microcontroller and displayed a key
switch being pressed in the board
EXPERIMENT 5
Interfacing Stepper Motor with PIC16F877A
Half-Drive
When alternatively one and two phases are energized, the motor will run in half
drive mode. It’s used to increase the angular resolution. Drawback is less torque
produced in this movement.
Wave Drive
In this mode, one stator electromagnet is turned on. Its follows 4 steps same as
Full-drive mode. It consumes low power with low torque.
Procedure:
1. Design the circuit shown below, components used are PIC16F877A ,stepper
motor, driver circuit
2. Code the program in MPLAB in .c and build the program code.
3. Get the hex file path and load it to PIC16F877A in our circuit in proteus
software.
4. Run the simulation and obtain the required results.
Program Code:
Output:
Result:
Successfully Interfaced a stepper motor PIC16F877A microcontroller and rotate
the motor in both direction.
EXPERIMENT 6
Interface built in DS1307 real time clock chip and display time,
day and date
Aim: To Interface DS1307 real time clock chip with PIC16F877A and
display the time, day and date.
DS1307 uses I2C Protocol and acts as a slave device and I2C Master
can read/write the register of RTC. To communicate with the slave
device, the master needs the slave address of a device connected to
the bus. DS1307 has a fixed slave address which makes it impossible
to connect two RTC devices on the same bus, don’t worry occurrence
of such a scenario is close to zero.
Circuit Diagram:
Program Code:
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS
oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT
disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit
(PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR
enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply)
In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on
MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code
Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write
Enable bits (Write protection off; all program memory may be written
to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code
Protection bit (Code protection off)
#include <xc.h>
#include<pic.h>
#include"lcd.h"
void main()
{
lcd_init();
show("Time:");
cmd(0xc0);
show("Date:");
rtc_int();
while(1) {
sec =rtc_read_byte(0x00);
min =rtc_read_byte(0x01);
hour =rtc_read_byte(0x02);
day =rtc_read_byte(0x03);
date =rtc_read_byte(0x04);
month=rtc_read_byte(0x05);
year =rtc_read_byte(0x06);
cmd(0x85);
dat(convup(hour));
dat(convd(hour));
dat(':');
dat(convup(min));
dat(convd(min));
dat(':');
dat(convup(sec));
dat(convd(sec));
cmd(0xc5);
dat(convup(date));
dat(convd(date));
dat(':');
dat(convup(month));
dat(convd(month));
dat(':');
dat(convup(year));
dat(convd(year));
dat('/');
dat(convup(day));
dat(convd(day));
}
}
void rtc_int()
{
TRISC3=TRISC4=1;
SSPCON=0x28;
SSPADD= (((11059200/4)/100)-1);
}
void waitmssp()
{
while(!SSPIF); // SSPIF is zero while TXion is progress
SSPIF=0;
}
void rtc_start()
{
SEN=1;
waitmssp();
}
void rtc_stop()
{
PEN=1;
waitmssp();
}
void rtc_res()
{
RSEN=1;
waitmssp();
}
void rtc_ack()
{
ACKDT=0;
ACKEN=1;
waitmssp();
}
void rtc_nak()
{
ACKDT=1;
ACKEN=1;
waitmssp();
}
return ((bcd>>4)+48);
}
Result:
Successfully Interfaced DS1307 real time clock chip with
PIC16F877A and displayed the time, day and date.
EXPERIMENT 7
Familiarization of deployment flow ARM Development
Kit, Keil Mvision IDE, Flash Programming
Deployment flow ARM Development Kit:
● Install the necessary development tools and IDEs, such as Keil MDK,
ARM Development Studio, or IAR Embedded Workbench.
● Ensure that you have the required drivers and software libraries for
your specific ARM-based microcontroller or processor.
4. Compilation:
● Compile your code to generate a binary or executable file that can run
on the ARM-based microcontroller or processor.
● The compiler optimizes the code for the specific ARM architecture you
are targeting.
Keil MDK provides a comprehensive set of tools and features for embedded
system development, including:
● Keil MDK offers a user-friendly IDE where you can write, compile, and
debug your embedded software.
● It supports various programming languages like C and assembly.
2. Compiler:
3. Debugger:
4. Peripheral Simulation:
● Keil MDK provides simulation capabilities that allow you to test your
code without needing physical hardware.
● You can simulate the behavior of microcontroller peripherals and test
your software in a controlled environment.
5. RTOS (Real-Time Operating System) Support:
6. Device-specific Packs:
● It integrates with version control systems like Git, making it easier for
teams to collaborate on embedded projects.
● Keil MDK includes a library of code templates and examples for various
microcontrollers and peripherals.
● These templates can help you get started quickly and serve as a
reference for best practices.
9. IDE Extensions:
● You can extend the functionality of Keil MDK through plugins and
extensions to tailor it to your specific project requirements.
Flash Programming:
● Before you can program the flash memory, you need to have the
compiled binary or hex file of your firmware.
● This file contains the machine code generated from your source code
(written in C/C++ or assembly).
● Before writing new firmware, it's often necessary to erase the existing
contents of the flash memory.
● This step ensures that no remnants of old firmware interfere with the
new one.
● The erasing process may be complete or sector-based, depending on
the microcontroller.
● After programming, it's a good practice to verify that the written data
matches the original binary file.
● Verification ensures that the programming process is successful and
that the firmware in flash memory is consistent with your intended
code.
THEORY:
2. Harvard Architecture:
3. Pipeline Architecture:
8. Clock Speeds:
PROCEDURE:
● Once you have a project open, you need to configure various project
settings.
● Set the microcontroller or processor type and clock configuration in the
project settings.
● You may also need to configure memory settings, debug settings, and
other project-specific options.
● Build your project by clicking the "Build" button (or pressing F7).
● The compiler will compile your source code and generate an output
binary file (e.g., a .hex or .bin file) that contains the machine code.
PROGRAM:
#include<LPC17xx.h>
int main()
{
uint32_t i;
LPC_GPIO1->FIODIR|=1<<31;
SystemInit();
while(1)
{
LPC_GPIO1->FIOSET|=1<<31;//on
for(i=0;i<10000000;i++);//for delay
LPC_GPIO1->FIOCLR|=1<<31;//off
for(i=0;i<10000000;i++);
# include <lpc17xx.h>
int getpinstate(int pin_no);
int main()
{
SystemInit();
LPC_GPIO2->FIODIR&=~(1<<10); // TO MAKE PIN AS INPUT P2.10
which is the switch
LPC_GPIO1->FIODIR|=(1<<31);// TO MAKE P1.31 OUTPUT
while(1)
{
if(getpinstate(10))
{
LPC_GPIO1->FIOSET |=1<<31;
}
else
{
LPC_GPIO1->FIOCLR |=1<<31;
}
}
}
int getpinstate(int pin_no)
{
int state= LPC_GPIO2->FIOPIN; // LPC_GPIO0-
>FIOPIN|=1<<10,TOCHECK WHETHER 10TH PIN STATUS IS 1 OR
NOT
int read=state&(1<<pin_no)?1:0;
return read;
}
# include <lpc17xx.h>
int getpinstate(int pin_no);
int main()
{
SystemInit();
LPC_GPIO1->FIODIR&=~(1<<25); // TO MAKE PIN AS INPUT
P1.25(to make pin as input ANDing will be done;left shifting one 25
times
LPC_GPIO1->FIODIR|=(1<<29);// TO MAKE P1.29 OUTPUT,to
make pin as output OR ing will be done,left shifting 1 25 times and
ORing
while(1)
{
//GLCD_DisplayChar(2,2,2,'0');
if(getpinstate(25))//if pinno 25 is 1 in joystick
{
LPC_GPIO1->FIOSET |=1<<29;//then led at pin p1.29
should blink,since it is p1.29,lpc_gpio1
}
else
{
LPC_GPIO1->FIOCLR |=1<<29;//off ing it
}
}
}
int getpinstate(int pin_no)
{
int state= LPC_GPIO1->FIOPIN;
int read=state&(1<<pin_no)?1:0;//shifting 1 at pin_no times and and
ing with state and check whether it is 1 or 0
return read;
}
RESULT:
Flashed a sample blinky program into ARM Cortex M3 and got the necessary
output.
EXPERIMENT - 8
Familiarization with Ulink pro
Ulink Pro:
The ULINK Pro is a popular debugging and programming tool used in
embedded systems development, particularly with ARM-based
microcontrollers. It provides various features and capabilities for developers
to effectively debug, flash, and analyze code running on target
microcontrollers. Here's an overview of the theory and key features of the
ULINK Pro:
● Trace: Some ULINK Pro variants offer trace capabilities, allowing you
to capture detailed program execution information. Trace data is
valuable for in-depth analysis of code behavior and performance
optimization.
2. Flash Programming:
● ULINK Pro can program the target microcontroller's flash memory with
compiled firmware.
3. Debug Interfaces:
● ULINK Pro supports real-time data transfer between the host computer
and the target microcontroller.
6. Compatibility:
7. JTAG/SWD Debugging:
● ULINK Pro often supports both JTAG and SWD debugging protocols,
making it versatile and compatible with various ARM microcontrollers.
9. Code Optimization:
● While ULINK Pro itself doesn't perform code optimizations, it helps
developers identify and analyze code optimizations performed by the
compiler or processor.
● This is crucial for diagnosing and fixing issues during development and
testing.
THEORY:
2. Harvard Architecture:
8. Clock Speeds:
● Once you have a project open, you need to configure various project
settings.
● Set the microcontroller or processor type and clock configuration in the
project settings.
● You may also need to configure memory settings, debug settings, and
other project-specific options.
● Build your project by clicking the "Build" button (or pressing F7).
● The compiler will compile your source code and generate an output
binary file (e.g., a .hex or .bin file) that contains the machine code.
6. Load the Program:
PROGRAM CODE:
#include<lpc17xx.h>
int main()
{
int i,sum=0;
for(i=0;i<=100;i++)
{
sum=sum+i;
}
}
RESULT:
To flash a sample program with a loop containing arithmetic operations.
EXPERIMENT - 9
Prime Numbers
AIM: To write a program to find the first 20 prime numbers and save it in an
array, run the program till N=20 and get the sum of all prime numbers.
THEORY:
2. Harvard Architecture:
3. Pipeline Architecture:
8. Clock Speeds:
PROCEDURE:
● Once you have a project open, you need to configure various project
settings.
● Set the microcontroller or processor type and clock configuration in the
project settings.
● You may also need to configure memory settings, debug settings, and
other project-specific options.
● Build your project by clicking the "Build" button (or pressing F7).
● The compiler will compile your source code and generate an output
binary file (e.g., a .hex or .bin file) that contains the machine code.
PROGRAM CODE
#include<lpc17xx.h>
int main()
int n,i=3,count,sum,c,a[20];
n=5;
sum = 0;
if(n>=1)
{
a[0]=2;
}
{
//iteration to check c is prime or not
{
if(i%c ==0)
break;
}
if(c == i) // c is prime
a[count-1]=i;
count++;
for(j=0;j<=count;j++)
}
}
return 0;
}
RESULT
wrote a program to find the first 20 prime numbers, saved them in an array,
ran the program till N=20, and got the sum of all prime numbers.