SlideShare a Scribd company logo
1 of 7
Download to read offline
#include //The global interrupt flag is maintained in the I bit of the status register (SREG).
#include //This header file includes the apropriate IO definitions for the device that has been
specified by the -mmcu= compiler command-line switch. This is done by diverting to the
appropriate file which should never be included directly. Some register names common to all
AVR devices are defined directly within , which is included in , but most of the details come
from the respective include file.
#include //The functions in this header file are wrappers around the basic busy-wait functions
from . They are meant as convenience functions where actual time values can be specified rather
than a number of cycles to wait for. The idea behind is that compile-time constant expressions
will be eliminated by compiler optimization so floating-point expressions can be used to
calculate the number of delay cycles needed based on the CPU frequency passed by the macro
F_CPU.
#include "oi.h"//This header file includes the apropriate IO definitions
//the #define directive allows the definition of macros within your source code. These macro
definitions allow constant values to be declared for use throughout your code. Macro definitions
are not variables and cannot be changed by your program code like variables.
#define USB 1
#define CR8 2 // toggle between usb and create on CM serial processor
//Methods used in program
void setSerial(uint8_t com);
uint8_t getSerialDestination(void);/*------------------------built in, sends back Serial Destination*/
void writeChar(char c, uint8_t com);/*------------ --taken from command modual manual. sends
data to computer via the USB cable*/
void delay(void);/* Checks the delayed period*/
void byteTx(uint8_t value);/*Transmit a byte over the serial port*/
void Init_Uart(void);/* Initialize the values */
uint8_t byteRx(void);/*------------------------------reads from the serial port*/
//This is main method for the program
void main(void)
{
uint8_t rx_data;
Init_Uart();
/* Writing the character by character using the while loop */
while(1)
{
writeChar('H',USB);
writeChar('e',USB);
writeChar('l',USB);
writeChar('l',USB);
writeChar('o',USB);
writeChar(' ',USB);
writeChar('W',USB);
writeChar('o',USB);
writeChar('r',USB);
writeChar('l',USB);
writeChar('d',USB);
writeChar('!',USB);
}
}
/*Initialize the values */
void Init_Uart(void)
{
UBRR0 = 59;
UCSR0B = 0x18;
UCSR0C = 0x06;
DDRB = 0X10;
PORTB = 0X10;
}
/*Used to check the delayed time */
void delay(void)
{
int i=0,j=0;
for(i=1;i<=1000;i++)
{
for(j=1;j<=1000;j++)
{
}
}
}
//****************************************************************************
****************
/*the following three functions came directly from the command module manual
they change the flow of data so that when byteTx is called it sends data
from the create to the computer through the USB cable. when it is done sending
data it returns the com port to its original state, giving commands to the create.
*/
//****************************************************************************
****************
uint8_t getSerialDestination(void)
{
if (PORTB & 0x10)
return USB;
else
return CR8;
}
void setSerial(uint8_t com)// uint8_t is unsigned char and com is its value
{//This is the condition of checking the value of unsigned char
if(com == USB)
PORTB |= 0x10;// |= is Bitwise inclusive OR and assignment operator.PORTB |= 0x10 is
same as PORTB=PORTB | 0x10
else if(com == CR8)
PORTB &= ~0x10;//&= is Bitwise AND assignment operator.PORTB &= ~0x10 meanse
PORTB = PORTB & ~0x10
}
//write char is called whenever you want to send data to the computer
void writeChar(char c, uint8_t com)
{
uint8_t originalDestination = getSerialDestination();
if (com != originalDestination)
{
setSerial(com);
delay();
}
byteTx((uint8_t)(c));
if (com != originalDestination)
{
setSerial(originalDestination);
delay();//Allow char to xmt
}
}
// Transmit a byte over the serial port
void byteTx(uint8_t value)
{
while(!(UCSR0A & 0x20)) ;
UDR0 = value;
}
uint8_t byteRx(void)
{
while(!(UCSR0A & 0x80)) ;
/* wait until a byte is received */
return UDR0;
}
Solution
#include //The global interrupt flag is maintained in the I bit of the status register (SREG).
#include //This header file includes the apropriate IO definitions for the device that has been
specified by the -mmcu= compiler command-line switch. This is done by diverting to the
appropriate file which should never be included directly. Some register names common to all
AVR devices are defined directly within , which is included in , but most of the details come
from the respective include file.
#include //The functions in this header file are wrappers around the basic busy-wait functions
from . They are meant as convenience functions where actual time values can be specified rather
than a number of cycles to wait for. The idea behind is that compile-time constant expressions
will be eliminated by compiler optimization so floating-point expressions can be used to
calculate the number of delay cycles needed based on the CPU frequency passed by the macro
F_CPU.
#include "oi.h"//This header file includes the apropriate IO definitions
//the #define directive allows the definition of macros within your source code. These macro
definitions allow constant values to be declared for use throughout your code. Macro definitions
are not variables and cannot be changed by your program code like variables.
#define USB 1
#define CR8 2 // toggle between usb and create on CM serial processor
//Methods used in program
void setSerial(uint8_t com);
uint8_t getSerialDestination(void);/*------------------------built in, sends back Serial Destination*/
void writeChar(char c, uint8_t com);/*------------ --taken from command modual manual. sends
data to computer via the USB cable*/
void delay(void);/* Checks the delayed period*/
void byteTx(uint8_t value);/*Transmit a byte over the serial port*/
void Init_Uart(void);/* Initialize the values */
uint8_t byteRx(void);/*------------------------------reads from the serial port*/
//This is main method for the program
void main(void)
{
uint8_t rx_data;
Init_Uart();
/* Writing the character by character using the while loop */
while(1)
{
writeChar('H',USB);
writeChar('e',USB);
writeChar('l',USB);
writeChar('l',USB);
writeChar('o',USB);
writeChar(' ',USB);
writeChar('W',USB);
writeChar('o',USB);
writeChar('r',USB);
writeChar('l',USB);
writeChar('d',USB);
writeChar('!',USB);
}
}
/*Initialize the values */
void Init_Uart(void)
{
UBRR0 = 59;
UCSR0B = 0x18;
UCSR0C = 0x06;
DDRB = 0X10;
PORTB = 0X10;
}
/*Used to check the delayed time */
void delay(void)
{
int i=0,j=0;
for(i=1;i<=1000;i++)
{
for(j=1;j<=1000;j++)
{
}
}
}
//****************************************************************************
****************
/*the following three functions came directly from the command module manual
they change the flow of data so that when byteTx is called it sends data
from the create to the computer through the USB cable. when it is done sending
data it returns the com port to its original state, giving commands to the create.
*/
//****************************************************************************
****************
uint8_t getSerialDestination(void)
{
if (PORTB & 0x10)
return USB;
else
return CR8;
}
void setSerial(uint8_t com)// uint8_t is unsigned char and com is its value
{//This is the condition of checking the value of unsigned char
if(com == USB)
PORTB |= 0x10;// |= is Bitwise inclusive OR and assignment operator.PORTB |= 0x10 is
same as PORTB=PORTB | 0x10
else if(com == CR8)
PORTB &= ~0x10;//&= is Bitwise AND assignment operator.PORTB &= ~0x10 meanse
PORTB = PORTB & ~0x10
}
//write char is called whenever you want to send data to the computer
void writeChar(char c, uint8_t com)
{
uint8_t originalDestination = getSerialDestination();
if (com != originalDestination)
{
setSerial(com);
delay();
}
byteTx((uint8_t)(c));
if (com != originalDestination)
{
setSerial(originalDestination);
delay();//Allow char to xmt
}
}
// Transmit a byte over the serial port
void byteTx(uint8_t value)
{
while(!(UCSR0A & 0x20)) ;
UDR0 = value;
}
uint8_t byteRx(void)
{
while(!(UCSR0A & 0x80)) ;
/* wait until a byte is received */
return UDR0;
}

More Related Content

Similar to #include avrinterrupt.h The global interrupt flag is maintained.pdf

Unix system programming
Unix system programmingUnix system programming
Unix system programmingSyed Mustafa
 
Linux Porting
Linux PortingLinux Porting
Linux PortingChamp Yen
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Bare metal performance in Elixir
Bare metal performance in ElixirBare metal performance in Elixir
Bare metal performance in ElixirAaron Seigo
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdfajay1317
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3Raahul Raghavan
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxadampcarr67227
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfarmyshoes
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Macpaul Lin
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Unit 4
Unit 4Unit 4
Unit 4siddr
 
Roll your own toy unix clone os
Roll your own toy unix clone osRoll your own toy unix clone os
Roll your own toy unix clone oseramax
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorialhughpearse
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bChereCheek752
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 

Similar to #include avrinterrupt.h The global interrupt flag is maintained.pdf (20)

Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Bare metal performance in Elixir
Bare metal performance in ElixirBare metal performance in Elixir
Bare metal performance in Elixir
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdf
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Unit 4
Unit 4Unit 4
Unit 4
 
Roll your own toy unix clone os
Roll your own toy unix clone osRoll your own toy unix clone os
Roll your own toy unix clone os
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
C programming session9 -
C programming  session9 -C programming  session9 -
C programming session9 -
 

More from arasanlethers

#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf
#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf
#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdfarasanlethers
 
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdf
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdfC, D, and E are wrong and involve random constants. Thisnarrows it d.pdf
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdfarasanlethers
 
AnswerOogenesis is the process by which ovum mother cells or oogo.pdf
AnswerOogenesis is the process by which ovum mother cells or oogo.pdfAnswerOogenesis is the process by which ovum mother cells or oogo.pdf
AnswerOogenesis is the process by which ovum mother cells or oogo.pdfarasanlethers
 
AnswerB) S. typhimuium gains access to the host by crossing the.pdf
AnswerB) S. typhimuium gains access to the host by crossing the.pdfAnswerB) S. typhimuium gains access to the host by crossing the.pdf
AnswerB) S. typhimuium gains access to the host by crossing the.pdfarasanlethers
 
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdf
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdfAnswer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdf
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdfarasanlethers
 
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdf
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdfA Letter to myself!Hi to myself!Now that I am an Engineer with a.pdf
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdfarasanlethers
 
Particulars Amount ($) Millons a) Purchase consideratio.pdf
     Particulars  Amount ($) Millons          a) Purchase consideratio.pdf     Particulars  Amount ($) Millons          a) Purchase consideratio.pdf
Particulars Amount ($) Millons a) Purchase consideratio.pdfarasanlethers
 
2 = 14.191,     df = 9,2df = 1.58 ,         P(2 14.191) = .pdf
2 = 14.191,     df = 9,2df = 1.58 ,         P(2  14.191) = .pdf2 = 14.191,     df = 9,2df = 1.58 ,         P(2  14.191) = .pdf
2 = 14.191,     df = 9,2df = 1.58 ,         P(2 14.191) = .pdfarasanlethers
 
while determining the pH the pH of the water is n.pdf
                     while determining the pH the pH of the water is n.pdf                     while determining the pH the pH of the water is n.pdf
while determining the pH the pH of the water is n.pdfarasanlethers
 
Quantum Numbers and Atomic Orbitals By solving t.pdf
                     Quantum Numbers and Atomic Orbitals  By solving t.pdf                     Quantum Numbers and Atomic Orbitals  By solving t.pdf
Quantum Numbers and Atomic Orbitals By solving t.pdfarasanlethers
 
They are molecules that are mirror images of each.pdf
                     They are molecules that are mirror images of each.pdf                     They are molecules that are mirror images of each.pdf
They are molecules that are mirror images of each.pdfarasanlethers
 
Well u put so many type of compounds here.Generally speakingi) t.pdf
Well u put so many type of compounds here.Generally speakingi) t.pdfWell u put so many type of compounds here.Generally speakingi) t.pdf
Well u put so many type of compounds here.Generally speakingi) t.pdfarasanlethers
 
Ventilation is the process of air going in and out of lungs. Increas.pdf
Ventilation is the process of air going in and out of lungs. Increas.pdfVentilation is the process of air going in and out of lungs. Increas.pdf
Ventilation is the process of air going in and out of lungs. Increas.pdfarasanlethers
 
A1) A living being or an individual is known as an organism and it i.pdf
A1) A living being or an individual is known as an organism and it i.pdfA1) A living being or an individual is known as an organism and it i.pdf
A1) A living being or an individual is known as an organism and it i.pdfarasanlethers
 
there are laws and regulations that would pertain to an online breac.pdf
there are laws and regulations that would pertain to an online breac.pdfthere are laws and regulations that would pertain to an online breac.pdf
there are laws and regulations that would pertain to an online breac.pdfarasanlethers
 
The false statement among the given list is “Territoriality means ho.pdf
The false statement among the given list is “Territoriality means ho.pdfThe false statement among the given list is “Territoriality means ho.pdf
The false statement among the given list is “Territoriality means ho.pdfarasanlethers
 
The current article is discussing about the role of SOX4 geneprotei.pdf
The current article is discussing about the role of SOX4 geneprotei.pdfThe current article is discussing about the role of SOX4 geneprotei.pdf
The current article is discussing about the role of SOX4 geneprotei.pdfarasanlethers
 
The major similarities between rocks and minerals are as follows1.pdf
The major similarities between rocks and minerals are as follows1.pdfThe major similarities between rocks and minerals are as follows1.pdf
The major similarities between rocks and minerals are as follows1.pdfarasanlethers
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfarasanlethers
 
main.cpp #include iostream #include iomanip #include S.pdf
main.cpp #include iostream #include iomanip #include S.pdfmain.cpp #include iostream #include iomanip #include S.pdf
main.cpp #include iostream #include iomanip #include S.pdfarasanlethers
 

More from arasanlethers (20)

#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf
#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf
#include SDLSDL.hSDL_Surface Background = NULL; SDL_Surface.pdf
 
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdf
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdfC, D, and E are wrong and involve random constants. Thisnarrows it d.pdf
C, D, and E are wrong and involve random constants. Thisnarrows it d.pdf
 
AnswerOogenesis is the process by which ovum mother cells or oogo.pdf
AnswerOogenesis is the process by which ovum mother cells or oogo.pdfAnswerOogenesis is the process by which ovum mother cells or oogo.pdf
AnswerOogenesis is the process by which ovum mother cells or oogo.pdf
 
AnswerB) S. typhimuium gains access to the host by crossing the.pdf
AnswerB) S. typhimuium gains access to the host by crossing the.pdfAnswerB) S. typhimuium gains access to the host by crossing the.pdf
AnswerB) S. typhimuium gains access to the host by crossing the.pdf
 
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdf
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdfAnswer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdf
Answer question1,2,4,5Ion–dipole interactionsAffinity of oxygen .pdf
 
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdf
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdfA Letter to myself!Hi to myself!Now that I am an Engineer with a.pdf
A Letter to myself!Hi to myself!Now that I am an Engineer with a.pdf
 
Particulars Amount ($) Millons a) Purchase consideratio.pdf
     Particulars  Amount ($) Millons          a) Purchase consideratio.pdf     Particulars  Amount ($) Millons          a) Purchase consideratio.pdf
Particulars Amount ($) Millons a) Purchase consideratio.pdf
 
2 = 14.191,     df = 9,2df = 1.58 ,         P(2 14.191) = .pdf
2 = 14.191,     df = 9,2df = 1.58 ,         P(2  14.191) = .pdf2 = 14.191,     df = 9,2df = 1.58 ,         P(2  14.191) = .pdf
2 = 14.191,     df = 9,2df = 1.58 ,         P(2 14.191) = .pdf
 
while determining the pH the pH of the water is n.pdf
                     while determining the pH the pH of the water is n.pdf                     while determining the pH the pH of the water is n.pdf
while determining the pH the pH of the water is n.pdf
 
Quantum Numbers and Atomic Orbitals By solving t.pdf
                     Quantum Numbers and Atomic Orbitals  By solving t.pdf                     Quantum Numbers and Atomic Orbitals  By solving t.pdf
Quantum Numbers and Atomic Orbitals By solving t.pdf
 
They are molecules that are mirror images of each.pdf
                     They are molecules that are mirror images of each.pdf                     They are molecules that are mirror images of each.pdf
They are molecules that are mirror images of each.pdf
 
Well u put so many type of compounds here.Generally speakingi) t.pdf
Well u put so many type of compounds here.Generally speakingi) t.pdfWell u put so many type of compounds here.Generally speakingi) t.pdf
Well u put so many type of compounds here.Generally speakingi) t.pdf
 
Ventilation is the process of air going in and out of lungs. Increas.pdf
Ventilation is the process of air going in and out of lungs. Increas.pdfVentilation is the process of air going in and out of lungs. Increas.pdf
Ventilation is the process of air going in and out of lungs. Increas.pdf
 
A1) A living being or an individual is known as an organism and it i.pdf
A1) A living being or an individual is known as an organism and it i.pdfA1) A living being or an individual is known as an organism and it i.pdf
A1) A living being or an individual is known as an organism and it i.pdf
 
there are laws and regulations that would pertain to an online breac.pdf
there are laws and regulations that would pertain to an online breac.pdfthere are laws and regulations that would pertain to an online breac.pdf
there are laws and regulations that would pertain to an online breac.pdf
 
The false statement among the given list is “Territoriality means ho.pdf
The false statement among the given list is “Territoriality means ho.pdfThe false statement among the given list is “Territoriality means ho.pdf
The false statement among the given list is “Territoriality means ho.pdf
 
The current article is discussing about the role of SOX4 geneprotei.pdf
The current article is discussing about the role of SOX4 geneprotei.pdfThe current article is discussing about the role of SOX4 geneprotei.pdf
The current article is discussing about the role of SOX4 geneprotei.pdf
 
The major similarities between rocks and minerals are as follows1.pdf
The major similarities between rocks and minerals are as follows1.pdfThe major similarities between rocks and minerals are as follows1.pdf
The major similarities between rocks and minerals are as follows1.pdf
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdf
 
main.cpp #include iostream #include iomanip #include S.pdf
main.cpp #include iostream #include iomanip #include S.pdfmain.cpp #include iostream #include iomanip #include S.pdf
main.cpp #include iostream #include iomanip #include S.pdf
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

#include avrinterrupt.h The global interrupt flag is maintained.pdf

  • 1. #include //The global interrupt flag is maintained in the I bit of the status register (SREG). #include //This header file includes the apropriate IO definitions for the device that has been specified by the -mmcu= compiler command-line switch. This is done by diverting to the appropriate file which should never be included directly. Some register names common to all AVR devices are defined directly within , which is included in , but most of the details come from the respective include file. #include //The functions in this header file are wrappers around the basic busy-wait functions from . They are meant as convenience functions where actual time values can be specified rather than a number of cycles to wait for. The idea behind is that compile-time constant expressions will be eliminated by compiler optimization so floating-point expressions can be used to calculate the number of delay cycles needed based on the CPU frequency passed by the macro F_CPU. #include "oi.h"//This header file includes the apropriate IO definitions //the #define directive allows the definition of macros within your source code. These macro definitions allow constant values to be declared for use throughout your code. Macro definitions are not variables and cannot be changed by your program code like variables. #define USB 1 #define CR8 2 // toggle between usb and create on CM serial processor //Methods used in program void setSerial(uint8_t com); uint8_t getSerialDestination(void);/*------------------------built in, sends back Serial Destination*/ void writeChar(char c, uint8_t com);/*------------ --taken from command modual manual. sends data to computer via the USB cable*/ void delay(void);/* Checks the delayed period*/ void byteTx(uint8_t value);/*Transmit a byte over the serial port*/ void Init_Uart(void);/* Initialize the values */ uint8_t byteRx(void);/*------------------------------reads from the serial port*/ //This is main method for the program void main(void) { uint8_t rx_data; Init_Uart(); /* Writing the character by character using the while loop */ while(1)
  • 2. { writeChar('H',USB); writeChar('e',USB); writeChar('l',USB); writeChar('l',USB); writeChar('o',USB); writeChar(' ',USB); writeChar('W',USB); writeChar('o',USB); writeChar('r',USB); writeChar('l',USB); writeChar('d',USB); writeChar('!',USB); } } /*Initialize the values */ void Init_Uart(void) { UBRR0 = 59; UCSR0B = 0x18; UCSR0C = 0x06; DDRB = 0X10; PORTB = 0X10; } /*Used to check the delayed time */ void delay(void) { int i=0,j=0; for(i=1;i<=1000;i++) { for(j=1;j<=1000;j++) { } } } //****************************************************************************
  • 3. **************** /*the following three functions came directly from the command module manual they change the flow of data so that when byteTx is called it sends data from the create to the computer through the USB cable. when it is done sending data it returns the com port to its original state, giving commands to the create. */ //**************************************************************************** **************** uint8_t getSerialDestination(void) { if (PORTB & 0x10) return USB; else return CR8; } void setSerial(uint8_t com)// uint8_t is unsigned char and com is its value {//This is the condition of checking the value of unsigned char if(com == USB) PORTB |= 0x10;// |= is Bitwise inclusive OR and assignment operator.PORTB |= 0x10 is same as PORTB=PORTB | 0x10 else if(com == CR8) PORTB &= ~0x10;//&= is Bitwise AND assignment operator.PORTB &= ~0x10 meanse PORTB = PORTB & ~0x10 } //write char is called whenever you want to send data to the computer void writeChar(char c, uint8_t com) { uint8_t originalDestination = getSerialDestination(); if (com != originalDestination) { setSerial(com); delay(); } byteTx((uint8_t)(c)); if (com != originalDestination)
  • 4. { setSerial(originalDestination); delay();//Allow char to xmt } } // Transmit a byte over the serial port void byteTx(uint8_t value) { while(!(UCSR0A & 0x20)) ; UDR0 = value; } uint8_t byteRx(void) { while(!(UCSR0A & 0x80)) ; /* wait until a byte is received */ return UDR0; } Solution #include //The global interrupt flag is maintained in the I bit of the status register (SREG). #include //This header file includes the apropriate IO definitions for the device that has been specified by the -mmcu= compiler command-line switch. This is done by diverting to the appropriate file which should never be included directly. Some register names common to all AVR devices are defined directly within , which is included in , but most of the details come from the respective include file. #include //The functions in this header file are wrappers around the basic busy-wait functions from . They are meant as convenience functions where actual time values can be specified rather than a number of cycles to wait for. The idea behind is that compile-time constant expressions will be eliminated by compiler optimization so floating-point expressions can be used to calculate the number of delay cycles needed based on the CPU frequency passed by the macro F_CPU. #include "oi.h"//This header file includes the apropriate IO definitions //the #define directive allows the definition of macros within your source code. These macro definitions allow constant values to be declared for use throughout your code. Macro definitions are not variables and cannot be changed by your program code like variables.
  • 5. #define USB 1 #define CR8 2 // toggle between usb and create on CM serial processor //Methods used in program void setSerial(uint8_t com); uint8_t getSerialDestination(void);/*------------------------built in, sends back Serial Destination*/ void writeChar(char c, uint8_t com);/*------------ --taken from command modual manual. sends data to computer via the USB cable*/ void delay(void);/* Checks the delayed period*/ void byteTx(uint8_t value);/*Transmit a byte over the serial port*/ void Init_Uart(void);/* Initialize the values */ uint8_t byteRx(void);/*------------------------------reads from the serial port*/ //This is main method for the program void main(void) { uint8_t rx_data; Init_Uart(); /* Writing the character by character using the while loop */ while(1) { writeChar('H',USB); writeChar('e',USB); writeChar('l',USB); writeChar('l',USB); writeChar('o',USB); writeChar(' ',USB); writeChar('W',USB); writeChar('o',USB); writeChar('r',USB); writeChar('l',USB); writeChar('d',USB); writeChar('!',USB); } } /*Initialize the values */ void Init_Uart(void)
  • 6. { UBRR0 = 59; UCSR0B = 0x18; UCSR0C = 0x06; DDRB = 0X10; PORTB = 0X10; } /*Used to check the delayed time */ void delay(void) { int i=0,j=0; for(i=1;i<=1000;i++) { for(j=1;j<=1000;j++) { } } } //**************************************************************************** **************** /*the following three functions came directly from the command module manual they change the flow of data so that when byteTx is called it sends data from the create to the computer through the USB cable. when it is done sending data it returns the com port to its original state, giving commands to the create. */ //**************************************************************************** **************** uint8_t getSerialDestination(void) { if (PORTB & 0x10) return USB; else return CR8; } void setSerial(uint8_t com)// uint8_t is unsigned char and com is its value {//This is the condition of checking the value of unsigned char
  • 7. if(com == USB) PORTB |= 0x10;// |= is Bitwise inclusive OR and assignment operator.PORTB |= 0x10 is same as PORTB=PORTB | 0x10 else if(com == CR8) PORTB &= ~0x10;//&= is Bitwise AND assignment operator.PORTB &= ~0x10 meanse PORTB = PORTB & ~0x10 } //write char is called whenever you want to send data to the computer void writeChar(char c, uint8_t com) { uint8_t originalDestination = getSerialDestination(); if (com != originalDestination) { setSerial(com); delay(); } byteTx((uint8_t)(c)); if (com != originalDestination) { setSerial(originalDestination); delay();//Allow char to xmt } } // Transmit a byte over the serial port void byteTx(uint8_t value) { while(!(UCSR0A & 0x20)) ; UDR0 = value; } uint8_t byteRx(void) { while(!(UCSR0A & 0x80)) ; /* wait until a byte is received */ return UDR0; }