SlideShare a Scribd company logo
1 of 9
Download to read offline
Buzzer:
#include <lpc214x.h>
#define BUZZER_ON() IO1CLR=(1<<25)
#define BUZZER_OFF() IO1SET=(1<<25)
#define Count 100
void Buzzer_Delay(unsigned char j);
void Buzzer_Delay(unsigned char j)
{
unsigned int i;
for(;j>0;j--)
{
for(i=0; i<60000; i++);
}
}
int main(void)
{
PINSEL0 = 0x0000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
IO1DIR = (1<<25) ;
while(1)
{
BUZZER_ON();
Buzzer_Delay(Count);
BUZZER_OFF();
}
}
LCD:
#include "lcd.h"
unsigned char Name[]="MyName";
unsigned char Surname[] = "Surname";
int main (void)
{
init_lcd();
lcd_putstring(0,Name);
lcd_putstring(1,Surname);
while (1) ;
}
-------------------------------not required to write if not asked for it-------------------------------------------
#ifndef _LCD_H
#define _LCD_H
#define MAX_CHAR_IN_ONE_LINE 16
enum ROW_NUMBERS
{
LINE1,
LINE2
};
void init_lcd(void);
void lcd_putstring(unsigned char line, char *string);
void lcd_clear(void);
void lcd_backlight_on(void);
int lcd_gotoxy(unsigned int x, unsigned int y);
void lcd_putchar(int c);
#endif
Down counter:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
void delay();
int main(void)
{
unsigned int b=255;
TRISA = 0x0000;
while(1)
{
PORTA=b;
delay();
delay();
b--;
if (!b)
{
delay();
delay();
delay();
delay();
b = 255;
}
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
UP counter:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
void delay();
int main(void)
{
unsigned int b=1;
TRISA = 0x0000;
while(1)
{
PORTA=b;
delay();
delay();
b++;
if (!b)
{
delay();
delay();
delay();
delay();
b = 0x0000;
}
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
Left shift:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 1
void delay();
unsigned int counter;
int main(void)
{
int i;
TRISA = 0x0000;
counter = init_count;
while(1)
{
for(i=0;i<8;i++)
{
PORTA=counter;
delay();
counter = counter << 1;
}
counter = 1;
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
Right shift:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 128
void delay();
unsigned int counter;
int main(void)
{
int i;
TRISA = 0x0000;
counter = init_count;
while(1)
{
for(i=0;i<8;i++)
{
PORTA=counter;
delay();
counter = counter >> 1;
}
counter = 128;
}
}
void delay()
{
long int x;
for(x=0;x<60000;x++);
}
Voltage converter/ADC:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 128
int main(void)
{
unsigned int ADC_Result;
TRISA = 0x0000;
AD1CON1 = 0x80E4;
AD1CON2 = 0;
AD1CON3 = 0x1F05;
AD1CHS = 5;
TRISBbits.TRISB2 = 1;
TRISBbits.TRISB3 = 1;
AD1PCFGbits.PCFG5 = 0;
AD1CSSL = 0;
AD1CON1bits.ADON = 1;
while (1)
{
while(!AD1CON1bits.DONE);
ADC_Result = (long) ADC1BUF0;
ADC_Result >>= 7;
PORTA = (0x80 >> ADC_Result);
}
}
Note:
Device specific keywords in the program for ex: PORTA or TRISA etc are case sensitive.
Take care to ensure the cases in the program while executing.

More Related Content

What's hot

26. composite l2qtouchpad
26. composite l2qtouchpad26. composite l2qtouchpad
26. composite l2qtouchpad
Media4math
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
S Ayub
 

What's hot (20)

Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
 
Alu description[1]
Alu description[1]Alu description[1]
Alu description[1]
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Assignment#2
Assignment#2Assignment#2
Assignment#2
 
C test
C testC test
C test
 
Assignment#4a
Assignment#4aAssignment#4a
Assignment#4a
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programs
 
Flex sensor
Flex sensorFlex sensor
Flex sensor
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
C++20 features
C++20 features C++20 features
C++20 features
 
Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias
 
Assignment#7b
Assignment#7bAssignment#7b
Assignment#7b
 
Assignment#7a
Assignment#7aAssignment#7a
Assignment#7a
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog code
 
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kitNon overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
 
26. composite l2qtouchpad
26. composite l2qtouchpad26. composite l2qtouchpad
26. composite l2qtouchpad
 
Logic gates verification using universal gates
Logic gates verification using universal gatesLogic gates verification using universal gates
Logic gates verification using universal gates
 
Direct analog
Direct analogDirect analog
Direct analog
 
Introduction to mazey
Introduction to mazeyIntroduction to mazey
Introduction to mazey
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 

Similar to Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018

Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timer
HEATLBJ
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
anishgoel
 
Home automation system
Home automation system Home automation system
Home automation system
Hira Shaukat
 

Similar to Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018 (20)

codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timer
 
C# Assignmet Help
C# Assignmet HelpC# Assignmet Help
C# Assignmet Help
 
8051 -5
8051 -58051 -5
8051 -5
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdf
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
Samrt attendance system using fingerprint
Samrt attendance system using fingerprintSamrt attendance system using fingerprint
Samrt attendance system using fingerprint
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinh
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
 
include.docx
include.docxinclude.docx
include.docx
 
Home automation system
Home automation system Home automation system
Home automation system
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
Operating system and embedded systems
Operating system and embedded systemsOperating system and embedded systems
Operating system and embedded systems
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 

More from UVCE

20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
UVCE
 
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS 20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
UVCE
 

More from UVCE (17)

Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018
 
3rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee60183rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee6018
 
8 th sem syllabus
8 th sem syllabus8 th sem syllabus
8 th sem syllabus
 
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...
 
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
 
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS 20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
 
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
 
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
 
OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE
 
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE60188th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
 
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
 
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
 
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
 
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018

  • 1. Buzzer: #include <lpc214x.h> #define BUZZER_ON() IO1CLR=(1<<25) #define BUZZER_OFF() IO1SET=(1<<25) #define Count 100 void Buzzer_Delay(unsigned char j); void Buzzer_Delay(unsigned char j) { unsigned int i; for(;j>0;j--) { for(i=0; i<60000; i++); } } int main(void) { PINSEL0 = 0x0000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; IO1DIR = (1<<25) ; while(1) { BUZZER_ON(); Buzzer_Delay(Count); BUZZER_OFF(); } }
  • 2. LCD: #include "lcd.h" unsigned char Name[]="MyName"; unsigned char Surname[] = "Surname"; int main (void) { init_lcd(); lcd_putstring(0,Name); lcd_putstring(1,Surname); while (1) ; } -------------------------------not required to write if not asked for it------------------------------------------- #ifndef _LCD_H #define _LCD_H #define MAX_CHAR_IN_ONE_LINE 16 enum ROW_NUMBERS { LINE1, LINE2 }; void init_lcd(void); void lcd_putstring(unsigned char line, char *string); void lcd_clear(void); void lcd_backlight_on(void); int lcd_gotoxy(unsigned int x, unsigned int y); void lcd_putchar(int c); #endif
  • 3. Down counter: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) void delay(); int main(void) { unsigned int b=255; TRISA = 0x0000; while(1) { PORTA=b; delay(); delay(); b--; if (!b) { delay(); delay(); delay(); delay(); b = 255; } } }
  • 4. void delay() { long int x; for(x=0;x<90000;x++); } UP counter: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) void delay(); int main(void) { unsigned int b=1; TRISA = 0x0000; while(1) { PORTA=b; delay(); delay(); b++; if (!b) { delay();
  • 5. delay(); delay(); delay(); b = 0x0000; } } } void delay() { long int x; for(x=0;x<90000;x++); } Left shift: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) #define init_count 1 void delay(); unsigned int counter; int main(void) { int i; TRISA = 0x0000; counter = init_count;
  • 6. while(1) { for(i=0;i<8;i++) { PORTA=counter; delay(); counter = counter << 1; } counter = 1; } } void delay() { long int x; for(x=0;x<90000;x++); } Right shift: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) #define init_count 128 void delay(); unsigned int counter; int main(void)
  • 7. { int i; TRISA = 0x0000; counter = init_count; while(1) { for(i=0;i<8;i++) { PORTA=counter; delay(); counter = counter >> 1; } counter = 128; } } void delay() { long int x; for(x=0;x<60000;x++); } Voltage converter/ADC: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
  • 8. #define init_count 128 int main(void) { unsigned int ADC_Result; TRISA = 0x0000; AD1CON1 = 0x80E4; AD1CON2 = 0; AD1CON3 = 0x1F05; AD1CHS = 5; TRISBbits.TRISB2 = 1; TRISBbits.TRISB3 = 1; AD1PCFGbits.PCFG5 = 0; AD1CSSL = 0; AD1CON1bits.ADON = 1; while (1) { while(!AD1CON1bits.DONE); ADC_Result = (long) ADC1BUF0; ADC_Result >>= 7; PORTA = (0x80 >> ADC_Result); } }
  • 9. Note: Device specific keywords in the program for ex: PORTA or TRISA etc are case sensitive. Take care to ensure the cases in the program while executing.