SlideShare a Scribd company logo
1 of 47
Download to read offline
The ARM Cortex-M4 Embedded Systems:
Tiva™ TM4C123GH6PM Microcontroller
General-Purpose Input/Outputs
Session 2
By: Zakriua Gomma
Email: zakriua.gomma37@gmail.com
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
• TM4C123 Overview:
• TM4C123GH6PM Overview:
• TM4C123GH6PM High-Level Block Diagram :
• TM4C123GH6PM High-Level Block Diagram :
• TM4C123GH6PM Overview:
• TM4C123GH6PM Overview:
In-Circuit Debug Interface(ICDL)
• TM4C123GH6PM Overview:
Virtual COM Port
• TM4C123GH6PM Overview:
Use Switches & RGB User LED
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
• General-Purpose Input/Outputs
• General-Purpose Input/Outputs
• TM4C123GH6PM Overview:
First Program :
Blink Led red & Green
• General-Purpose Input/Outputs
• General-Purpose Input/Outputs
1-First We Must deliver clock to GpioX Module
GpioX Module
Clock
Enable
Warning : IF you try to read or write in any Register in
GpioX Module without deliver Clock ,you will cause bus
fault Exception
• General-Purpose Input/Outputs
1- Clock
Run Mode Clock Gating Control Register 2 (RCGC2) :
• SYSCTL_RCGC2=0x20;
If 1 Port A will work
If 1 Port B will work
If 1 Port C will work
If 1 Port D will work
If 1 Port E will work
If 1 Port F will work
If 1 USB0 will work
If 1 Direct memory
access will work
• General-Purpose Input/Outputs
General-Purpose Input/Output Run Mode Clock Gating
Control(RCGCGPIO),
RCGCGPIO=0x20;
If 1 Port A will work
If 1 Port B will work
If 1 Port C will work
If 1 Port D will work
If 1 Port E will work
If 1 Port F will work
If 1 USB0 will work
This register should be used to control the clocking for the
GPIO modules. To support
legacy software, the RCGC2 register is available. A write to
the RCGC2 register also
writes the corresponding bit in this register.
The both do the same Job.
• General-Purpose Input/Outputs
2- GPIODIR
• General-Purpose Input/Outputs
2- GPIODIR
Input 0,output =1
• GPIO_PORTF_DIR=0X0A
=00001010 Means pin0,2,4,5,6,7 is input & pin 1,3 output
• General-Purpose Input/Outputs
3- GPIODEN (GPIO Digital Enable):
The GPIODEN (Digital Enable) special function register allows us to
enable the pin to be used as digital I/O pin instead of analog function.
Each PORT of A-F has its own GPIODEN register and one can enable the
digital I/O for each pin of a given port
GPIO_PORTF_DEN=0X0A
• General-Purpose Input/Outputs
4- GPIODATA
• General-Purpose Input/Outputs
4- GPIODATA
What that mean ?!
I can access to any pin directly without needing to (read-
modify-write operation to set or clear an individual
GPIO pin.)
#define GPIO_PORTF_DATA (*((volatile unsigned long *)0x40025028))
GPIO_PORTF_DATA=0X0A
Bit banding
• TM4C123GH6PM Overview:
Second Program :
Blink Led red & Green &Blue using switch 1&2
• TM4C123GH6PM Overview:
Second Program :
Blink Led red & Green &Blue using switch 1&2
1. #define GPIO_PORTF_DATA (*((volatile unsigned long *)0x4002507C)) to
acess pin 0 to pin 4
2. GPIO_PORTF_DIR=0X0E
3. GPIO_PORTF_DEN=0X0E;
4. After we deliver clock we will do the next
• General-Purpose Input/Outputs
2- GPIOLOCK
With Port C & Port F ,we need to write in GPIOLock Register
0x4C4F434B to can use all of pins of Port C &F , because some of this
pin can make damage to the internal Flash memory & microcontroller
Writing 0x4C4F434B In GPIOLock enable to write In GPIOCR
• General-Purpose Input/Outputs
3- GPIOCR
This register is designed to prevent accidental programming
of the registers that control connectivity to the NMI and
JTAG/SWD debug hardware. By initializing the bits of the
GPIOCR register to 0 for PD7, PF0, and PC[3:0].
• General-Purpose Input/Outputs
3- Un Excepted input
• General-Purpose Input/Outputs
3- Un Excepted input
In tiva-c is available internal Pull up Resistor &
internal pull down Resistor on every pin .
Switches on PF0,PF4 Is suitable For Pull up resistor
• General-Purpose Input/Outputs
3- GPIO Pull-Up Select (GPIOPUR)
GPIO Pull-down Select (GPIOPDR)
VCC
VCC
GND
GND
GPIOPUR
GPIOPDR
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
• Bitwise operators
operatorSymbol
bitwise AND&
bitwise inclusive OR|
bitwise XOR (eXclusive OR)^
left shift>>
right shift<<
bitwise NOT (one's complement)~
• Bitwise operators
– OR
– Xor
GPIO_PORTF_DATA=0X0A | 0x04
0b00001010
0b00000100=
0b00001110 =0x0E
GPIO_PORTF_DATA|=0x04 
GPIO_PORTF_DATA=0X0E^0x04
0b00001110
0b00000100=
0b00001010 =0x0A
GPIO_PORTF_DATA^=0x04 
• Bitwise operators
– Not
– And or Mask
GPIO_PORTF_DATA=0x0A
GPIO_PORTF_DATA=~GPIO_PORTF_DATA
0b00001010=
0b11110101 =0xF5
GPIO_PORTF_DATA~=0x0A 
GPIO_PORTF_DATA=0X0E&0x04
0b00001110
0b00000100=
0b00000100 =0x04
GPIO_PORTF_DATA&=0x04 
• Bitwise operators
– ( >>) right shift
– ( <<) left shift
Data>>Number of bit
GPIO_PORTF_DATA=0x0A>>1
0b00001010=
0b00000101 =0x05
GPIO_PORTF_DATA>>=1 
Data<<Number of bit
GPIO_PORTF_DATA=0x0A<<1
0b00001010=
0b00010100 =0x14
GPIO_PORTF_DATA<<=1 
• Bitwise operators
Exercise
GPIO_PORTF_DATA=0XFF;
GPIO_PORTF_DATA&=~(0X02);
Answer is GPIOF_PORTF_DATA=0XFD;
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
• System Timer (SysTick)
• Tiva-c includes an integrated system timer (SysTick) :
• SysTick is part of Cortex-M4 Core.
• SysTick is 24 bit timer wide.
• SysTick is use in RTOS operations .
• SysTick is decrement timer.
• 24 bit timer mean the timer can count 16777215
Cycle.
• With 16 MHz speed the SysTick can generate 1
second delay when count 16000000 cycles which
mean 15999999 because timer count to 0 .
• System Timer (SysTick)
Clock Diagram In Tiva-c
• System Timer (SysTick)
SysTick diagram In Tiva-c
PIOSC (Precision Internal OSC 16 MHz) .
System Clock can be from 32,768 KHz To 80 MHz .
• System Timer (SysTick)
SysTick consist from 3 Register :
• Register 1: SysTick Control and Status Register (STCTRL):
• Enable : 0 timer is disabled , 1 timer is enabled .
• INTEN : 0 Interrupt is disabled , 1 An interrupt is generated to the NVIC
when SysTick counts to 0.
• CLK_SRC : 0 (PIOSC) divided by 4 ,1 System clock.
• COUNT : 0 The SysTick timer has not counted to 0 yet , 1 The SysTick timer
has counted to 0 . This bit is cleared by a read of the register or if the
STCURRENT register is written with any value.
• System Timer (SysTick)
SysTick consist from 3 Register :
• Register 2: SysTick Reload Value Register (STRELOAD)
• The STRELOAD register specifies the start value to load into the SysTick
Current Value (STCURRENT) register when the counter reaches.
• The start value can be between 0x1 and 0x00FFFFFF.
• The STRELOAD should contain the value N – 1 for the COUNT to fire every
N clock cycles because the counter counts down to 0. For example, if we
need 1000 clocks of interval, then we make STRELOAD =999 .
• System Timer (SysTick)
SysTick consist from 3 Register :
• Register 3: SysTick Current Value Register (STCURRENT)
• The STRELOAD register specifies the start value to load into the SysTick
• This register is write-clear. Writing to it with any value clears the register.
Clearing this register also clears the COUNT bit of the STCTRL register .
• System Timer (SysTick)
Working with SysTick
I. We Must Disable SysTick during setup , STCTRL=0.
II. We put the value that SysTick count it in STRELOAD.
III. The value must be not more than 16777215 or FFFFFF .
IV. We Enable SysTick & choose the configurations.
V. STCTRL=0x05 (enable it, no interrupt, use system clock).
VI. Wait Flag
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
Agenda
 TM4C123 Overview
 General-Purpose Input/Outputs
 Bitwise operators
 System Timer (SysTick)
 Delay Library
 Interface 74595
• Interface 74595

More Related Content

What's hot

What's hot (20)

Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furber
 
Timers in Arduino
Timers in ArduinoTimers in Arduino
Timers in Arduino
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
ATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part I
 
Real time scheduling - basic concepts
Real time scheduling - basic conceptsReal time scheduling - basic concepts
Real time scheduling - basic concepts
 
Msp 430 architecture module 1
Msp 430 architecture module 1Msp 430 architecture module 1
Msp 430 architecture module 1
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systems
 
Unit 2 mpmc
Unit 2 mpmcUnit 2 mpmc
Unit 2 mpmc
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
06. thumb instructions
06. thumb instructions06. thumb instructions
06. thumb instructions
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
80486 and pentium
80486 and pentium80486 and pentium
80486 and pentium
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
UART
UART UART
UART
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 Course
 
Introduction to embedded system design
Introduction to embedded system designIntroduction to embedded system design
Introduction to embedded system design
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 

Similar to GPIO In Arm cortex-m4 tiva-c

8255.pdf
8255.pdf8255.pdf
8255.pdf
someshdash1
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers ii
Kumar Kumar
 

Similar to GPIO In Arm cortex-m4 tiva-c (20)

chapter 4
chapter 4chapter 4
chapter 4
 
8255.pdf
8255.pdf8255.pdf
8255.pdf
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
8051 MC.pptx
8051 MC.pptx8051 MC.pptx
8051 MC.pptx
 
MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.ppt
 
introduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.pptintroduction to Microcontrollers 8051.ppt
introduction to Microcontrollers 8051.ppt
 
Pin diagram of 8085
Pin diagram of 8085Pin diagram of 8085
Pin diagram of 8085
 
5 pin-diagram-of-8085-181203034237
5 pin-diagram-of-8085-1812030342375 pin-diagram-of-8085-181203034237
5 pin-diagram-of-8085-181203034237
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers ii
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
 
Lecture7
Lecture7Lecture7
Lecture7
 
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
moving message display of lcd
 moving message display of lcd moving message display of lcd
moving message display of lcd
 
MICROCONTROLLER.pptx
MICROCONTROLLER.pptxMICROCONTROLLER.pptx
MICROCONTROLLER.pptx
 
MicrocontrollersII (1).pptx
MicrocontrollersII (1).pptxMicrocontrollersII (1).pptx
MicrocontrollersII (1).pptx
 
Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,Embedded Systems,Embedded Systems Project,Winter training,
Embedded Systems,Embedded Systems Project,Winter training,
 
How to use peripherals on MCB1700
How to use peripherals on MCB1700How to use peripherals on MCB1700
How to use peripherals on MCB1700
 

Recently uploaded

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Recently uploaded (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 

GPIO In Arm cortex-m4 tiva-c

  • 1. The ARM Cortex-M4 Embedded Systems: Tiva™ TM4C123GH6PM Microcontroller General-Purpose Input/Outputs Session 2 By: Zakriua Gomma Email: zakriua.gomma37@gmail.com
  • 2. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595
  • 5. • TM4C123GH6PM High-Level Block Diagram :
  • 6. • TM4C123GH6PM High-Level Block Diagram :
  • 10. • TM4C123GH6PM Overview: Use Switches & RGB User LED
  • 11. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595
  • 14. • TM4C123GH6PM Overview: First Program : Blink Led red & Green
  • 16. • General-Purpose Input/Outputs 1-First We Must deliver clock to GpioX Module GpioX Module Clock Enable Warning : IF you try to read or write in any Register in GpioX Module without deliver Clock ,you will cause bus fault Exception
  • 17. • General-Purpose Input/Outputs 1- Clock Run Mode Clock Gating Control Register 2 (RCGC2) : • SYSCTL_RCGC2=0x20; If 1 Port A will work If 1 Port B will work If 1 Port C will work If 1 Port D will work If 1 Port E will work If 1 Port F will work If 1 USB0 will work If 1 Direct memory access will work
  • 18. • General-Purpose Input/Outputs General-Purpose Input/Output Run Mode Clock Gating Control(RCGCGPIO), RCGCGPIO=0x20; If 1 Port A will work If 1 Port B will work If 1 Port C will work If 1 Port D will work If 1 Port E will work If 1 Port F will work If 1 USB0 will work This register should be used to control the clocking for the GPIO modules. To support legacy software, the RCGC2 register is available. A write to the RCGC2 register also writes the corresponding bit in this register. The both do the same Job.
  • 20. • General-Purpose Input/Outputs 2- GPIODIR Input 0,output =1 • GPIO_PORTF_DIR=0X0A =00001010 Means pin0,2,4,5,6,7 is input & pin 1,3 output
  • 21. • General-Purpose Input/Outputs 3- GPIODEN (GPIO Digital Enable): The GPIODEN (Digital Enable) special function register allows us to enable the pin to be used as digital I/O pin instead of analog function. Each PORT of A-F has its own GPIODEN register and one can enable the digital I/O for each pin of a given port GPIO_PORTF_DEN=0X0A
  • 23. • General-Purpose Input/Outputs 4- GPIODATA What that mean ?! I can access to any pin directly without needing to (read- modify-write operation to set or clear an individual GPIO pin.) #define GPIO_PORTF_DATA (*((volatile unsigned long *)0x40025028)) GPIO_PORTF_DATA=0X0A Bit banding
  • 24. • TM4C123GH6PM Overview: Second Program : Blink Led red & Green &Blue using switch 1&2
  • 25. • TM4C123GH6PM Overview: Second Program : Blink Led red & Green &Blue using switch 1&2 1. #define GPIO_PORTF_DATA (*((volatile unsigned long *)0x4002507C)) to acess pin 0 to pin 4 2. GPIO_PORTF_DIR=0X0E 3. GPIO_PORTF_DEN=0X0E; 4. After we deliver clock we will do the next
  • 26. • General-Purpose Input/Outputs 2- GPIOLOCK With Port C & Port F ,we need to write in GPIOLock Register 0x4C4F434B to can use all of pins of Port C &F , because some of this pin can make damage to the internal Flash memory & microcontroller Writing 0x4C4F434B In GPIOLock enable to write In GPIOCR
  • 27. • General-Purpose Input/Outputs 3- GPIOCR This register is designed to prevent accidental programming of the registers that control connectivity to the NMI and JTAG/SWD debug hardware. By initializing the bits of the GPIOCR register to 0 for PD7, PF0, and PC[3:0].
  • 29. • General-Purpose Input/Outputs 3- Un Excepted input In tiva-c is available internal Pull up Resistor & internal pull down Resistor on every pin . Switches on PF0,PF4 Is suitable For Pull up resistor
  • 30. • General-Purpose Input/Outputs 3- GPIO Pull-Up Select (GPIOPUR) GPIO Pull-down Select (GPIOPDR) VCC VCC GND GND GPIOPUR GPIOPDR
  • 31. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595
  • 32. • Bitwise operators operatorSymbol bitwise AND& bitwise inclusive OR| bitwise XOR (eXclusive OR)^ left shift>> right shift<< bitwise NOT (one's complement)~
  • 33. • Bitwise operators – OR – Xor GPIO_PORTF_DATA=0X0A | 0x04 0b00001010 0b00000100= 0b00001110 =0x0E GPIO_PORTF_DATA|=0x04  GPIO_PORTF_DATA=0X0E^0x04 0b00001110 0b00000100= 0b00001010 =0x0A GPIO_PORTF_DATA^=0x04 
  • 34. • Bitwise operators – Not – And or Mask GPIO_PORTF_DATA=0x0A GPIO_PORTF_DATA=~GPIO_PORTF_DATA 0b00001010= 0b11110101 =0xF5 GPIO_PORTF_DATA~=0x0A  GPIO_PORTF_DATA=0X0E&0x04 0b00001110 0b00000100= 0b00000100 =0x04 GPIO_PORTF_DATA&=0x04 
  • 35. • Bitwise operators – ( >>) right shift – ( <<) left shift Data>>Number of bit GPIO_PORTF_DATA=0x0A>>1 0b00001010= 0b00000101 =0x05 GPIO_PORTF_DATA>>=1  Data<<Number of bit GPIO_PORTF_DATA=0x0A<<1 0b00001010= 0b00010100 =0x14 GPIO_PORTF_DATA<<=1 
  • 37. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595
  • 38. • System Timer (SysTick) • Tiva-c includes an integrated system timer (SysTick) : • SysTick is part of Cortex-M4 Core. • SysTick is 24 bit timer wide. • SysTick is use in RTOS operations . • SysTick is decrement timer. • 24 bit timer mean the timer can count 16777215 Cycle. • With 16 MHz speed the SysTick can generate 1 second delay when count 16000000 cycles which mean 15999999 because timer count to 0 .
  • 39. • System Timer (SysTick) Clock Diagram In Tiva-c
  • 40. • System Timer (SysTick) SysTick diagram In Tiva-c PIOSC (Precision Internal OSC 16 MHz) . System Clock can be from 32,768 KHz To 80 MHz .
  • 41. • System Timer (SysTick) SysTick consist from 3 Register : • Register 1: SysTick Control and Status Register (STCTRL): • Enable : 0 timer is disabled , 1 timer is enabled . • INTEN : 0 Interrupt is disabled , 1 An interrupt is generated to the NVIC when SysTick counts to 0. • CLK_SRC : 0 (PIOSC) divided by 4 ,1 System clock. • COUNT : 0 The SysTick timer has not counted to 0 yet , 1 The SysTick timer has counted to 0 . This bit is cleared by a read of the register or if the STCURRENT register is written with any value.
  • 42. • System Timer (SysTick) SysTick consist from 3 Register : • Register 2: SysTick Reload Value Register (STRELOAD) • The STRELOAD register specifies the start value to load into the SysTick Current Value (STCURRENT) register when the counter reaches. • The start value can be between 0x1 and 0x00FFFFFF. • The STRELOAD should contain the value N – 1 for the COUNT to fire every N clock cycles because the counter counts down to 0. For example, if we need 1000 clocks of interval, then we make STRELOAD =999 .
  • 43. • System Timer (SysTick) SysTick consist from 3 Register : • Register 3: SysTick Current Value Register (STCURRENT) • The STRELOAD register specifies the start value to load into the SysTick • This register is write-clear. Writing to it with any value clears the register. Clearing this register also clears the COUNT bit of the STCTRL register .
  • 44. • System Timer (SysTick) Working with SysTick I. We Must Disable SysTick during setup , STCTRL=0. II. We put the value that SysTick count it in STRELOAD. III. The value must be not more than 16777215 or FFFFFF . IV. We Enable SysTick & choose the configurations. V. STCTRL=0x05 (enable it, no interrupt, use system clock). VI. Wait Flag
  • 45. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595
  • 46. Agenda  TM4C123 Overview  General-Purpose Input/Outputs  Bitwise operators  System Timer (SysTick)  Delay Library  Interface 74595