SlideShare a Scribd company logo
#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

Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
Rodrigo Almeida
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
Syed Mustafa
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
Champ 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 Elixir
Aaron 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 Kernel
Divye Kapoor
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens 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.pdf
ajay1317
 
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
Raahul 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.docx
adampcarr67227
 
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
armyshoes
 
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 os
eramax
 
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 b
ChereCheek752
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
Satpal Parmar
 
C programming session9 -
C programming  session9 -C programming  session9 -
C programming session9 -
Keroles karam khalil
 

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.pdf
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 
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
arasanlethers
 

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

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 

Recently uploaded (20)

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

#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; }