Let’s work with the SYSTEM CLOCK!

Slides:



Advertisements
Similar presentations
The 8085 Microprocessor Architecture
Advertisements

EET 2261 Unit 8 Seven-Segment Displays; S19 Records; System Clocks
Slide show Notes_04.ppt Another effect emerging from the Einstein’s postulates: Length contraction. We now turn the “light-clock” sideways. Suppose that.
Basic Stamp II is kinda cool Bytes of EEPROM(non-volatile) - Clock speed of 20 MHz. - Holds 600 lines of code in EEPROM - executes an average of.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
Registers  Flip-flops are available in a variety of configurations. A simple one with two independent D flip-flops with clear and preset signals is illustrated.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
GCSE Computing - The CPU
Input and Output Developed by: Electronic Systems Technologies College of Applied Sciences and Arts Southern Illinois University Carbondale
Group #5 1. Mereseini Rokodau 2. Eleanor Siavii 3. Jowella Vaka.
RM2F Input / Output (I/O) Pin grouping code!. I/O Pin Group Operations: The Spin language has provisions for assigning values to groups of bits in the.
B.A. (Mahayana Studies) Introduction to Computer Science November March The Motherboard A look at the brains of the computer, the.
COE4OI5 Engineering Design Chapter 2: UP2/UP3 board.
Computer Processing of Data
System Clocks.
D75P 34 – HNC Computer Architecture Lecture 14 Clock Cycles and Program Analysis. © C Nyssen/Aberdeen College 2003 All images © C Nyssen/Aberdeen College.
RM2D Let’s write our FIRST basic SPIN program!. The Labs that follow in this Module are designed to teach the following; Turn an LED on – assigning I/O.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
10/10/ Controlling YOUR ROBOT. 10/10/2015 Basic Stamp  Basic Stamp Input - output pins Interpreter Chip Power supply: 5 Volts voltage Memory: EEPROM.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
Parts of the computer.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
1 System Clock and Clock Synchronization.. System Clock Background Although modern computers are quite fast and getting faster all the time, they still.
July 7, 2003 Slide 1 of 6 Automation, Robotics and Mechatronics Lab, SUNY at Buffalo Introduction To Programming Chetan Jadhav Talib Bhabharawala Seung-Kook.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
Identifying Hardware Components in a Computer (continued) Clock Speed (continued) The computer has a system clock that generates a regular electronic beat.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Net+Os v5.1 with GHS 3.5 & GNU. What it is… Inter Release that allows you to run Net+Os on 7520 based targets… The BSP has been restructured to make it.
MEMORY is part of the Central Processing Unit, or CPU, where data and information are stored. There are two main types of memory in a computer – RAM.
Atmega328p Introduction for Digital and PWM Output Brion L Fuller II Robotics Club.
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
EET 2261 Unit 13 Enhanced Capture Timer
Introduction to Programming in RobotC
Making a 24hr Timer.
Computer Hardware What is a CPU.
GCSE Computing - The CPU
Clock Signals: 555 Timer 555 Timer Digital Electronics TM
The 8085 Microprocessor Architecture
Chapter 2.1 CPU.
Ozoblockly Lesson 03 Beginner Programs
Programming and File Management Part 2
UTA010 : Engineering Design – II
The 8085 Microprocessor Architecture
THE CPU i Bytes 1.1.
Chapter 5 Conclusion CIS 61.
Programming Scratch to Control a K’NEX Fairground Ride
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
BBC Microbit.
Welcome to Digital Electronics using the Arduino Board
555 Timer 555 Timer Digital Electronics TM 1.2 Introduction to Analog
Controlling YOUR ROBOT
An Introduction to VEX IQ Programming with Modkit
Computer Organization
555 Timer 555 Timer Digital Electronics TM 1.2 Introduction to Analog
The 8085 Microprocessor Architecture
Arduino Part 4 Let there be more light.
Spin Tara Crunk  Alex Douglas  Akhila Yeruva Sources:
Python programming exercise
Overview 1. Inside a PC 2. The Motherboard 3. RAM the 'brains' 4. ROM
ECE 352 Digital System Fundamentals
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino Uno circuit basics
GCSE Computing - The CPU
Let’s use a PUSH-Button!
Course Code 114 Introduction to Computer Science
Objective of the lesson
Presentation transcript:

Let’s work with the SYSTEM CLOCK! RM2H Let’s work with the SYSTEM CLOCK!

Now we are going to move on to work with the system clock! Timing Delays with the System Clock Certain I/O operations are much easier to study with code that controls the timing of certain events, such as when an LED lights or how long a pushbutton is pressed. The three basic Spin building blocks for event timing are: 1. cnt – a register in the Propeller chip that counts system clock ticks. 2. clkfreq – a command that returns the Propeller chip’s system clock frequency in Hz.(Think of it is as a value that stores the number of Propeller system clock ticks in one second.) 3. waitcnt – a command that waits for the cnt register to get to a certain value.

If we really want to get fancy, we write; Essentially, this is the way waitcnt works: Lets use an example; waitcnt(clkfreq + cnt) ‘ causes the program to WAIT for 1 second, then move on. To create a delay that lasts only a FRACTION of a second, the code would look like this; waitcnt(clkfreq/3 + cnt) ‘ this command causes a delay for 1/3 of a second, then moves on. If we really want to get fancy, we write; waitcnt(clkfreq/1000 + cnt) ‘ now it waits for 1 Millisecond before it moves on!

Lets try writing some code for this: ‘File: LEDOnOffP20.spin PUB LEDOnOff dira[20] := 1 repeat outa[20] := 1 waitcnt(clkfreq/4 + cnt) outa[20] := 0 waitcnt(clkfreq/4*3 + cnt) Load the program LEDOnOffP16.spin into RAM or EEPROM by selecting F10 or F11.

So what happened? 2. Can you figure out what the flash rate is? 1. Is the LED flashing? 2. Can you figure out what the flash rate is? (for example..how long does it stay on then go off?) 3. Put your BRAIN in GEAR! Can you figure out a way to make the LED Stay on for 1 second and stay OFF for 3 seconds? TRY IT!

INDENTATION IS CRITICAL! In case you have missed it, indentation when writing spin code is VERY important! Whenever you have commands that need to be linked together such as commands that follow a repeat command, be sure the code below is INDENTED to avoid unexpected results!

The BLUE area shown below should be shown in GREY in the Parallax Propeller Tool program when indenting! repeat outa[20] := 1 waitcnt(clkfreq/4 + cnt) outa[20] := 0 waitcnt(clkfreq/4*3 + cnt)

Quick info on the waitcnt command: If you write the code: waitcnt(clkfreq + cnt) it’s the SAME as waitcnt(12_000_000 + cnt) Essentially, it’s the Propeller chips DEFAULT clock. If we want to change the system clock to speed it up or slow it down, we use special code in the CON block to do that. Be aware that if NO Clock Config Constant (CON) is set, the Propeller will use the default setting. Let’s take a look in the next slide!

Let’s break down the SPECIFICS! CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll16x The code is broken down like this; _xinfreq = 5_000_000 ‘ defines the expected frequency from the crystal (Oscillator) on the circuit board. (It’s the silver looking can) In our case the crystal is 5 Mhz (5 Megahertz = 5 Million cycles per second) _clkmode = xtal1 + pll16x ‘ _clkmode sets the chip into clock mode. xtal1 configures the PROP chip to work with our external crystal. Pll16x tells the PROP chip to set its Phase Locked Loop (pll) circuitry to multiply the 5Mhz crystal value X 16. …………... so 16 X 5Mhz = 80 Mhz!

That’s Pretty Cool STUFF! Now you know how to change the time on a PROP chip so that you can make the chip turn something ON or OFF at a rate you want! Just think..it only takes a little math to make this chip do some interesting things!

***IMPORTANT*** The EXTERNAL crystal is ACCURATE when used with correctly written code…. HOWEVER, the PROP chips INTERNAL timing is NOT very accurate. SO….If you want to make something work within a timing sequence and you want the time to be accurate…you need to use the EXTERNAL CRYSTAL to set the timing. (This means you have to write the CON block of code to set the external crystal to work!)

Let’s write some code to try this out! ‘’File: ConstantBlinkRate.spin CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll16x PUB LEDonOFF dira[16] := 1 repeat outa[16] := 1 waitcnt (clkfreq/2 + cnt) outa[16] := 0 Load the program ConstantBlinkRate.spin into RAM or EEPROM by selecting F10 or F11.

See the next slide to break it down a little further! So what happened? 1. Is the LED connected to P20 flashing? 2. Is it flashing 1 time every second? (remember that 1 flash per second = 1 Hz) 3. Can you explain how the PROP knows to flash the LED one time per second? See the next slide to break it down a little further!

A little more info on clkfreq: When you write the code; waitcnt(clkfreq/2 + cnt) ‘ the waitcnt is like a pause while the cnt register counts clock ticks. The clkfreq command returns the number of ticks PER SECOND (Based on the PROP chips clock settings) So…even though the _clkmode = xtal1 + pll16x tells the PROP to run at 80 Mhz, this has NO effect on the flash rate. This is just telling the PROP chip at what speed to run!

Let’s make a change in the code and test it out! Only 1 change was made in your previous code! Change your 16 to an 8. (This sets the system clock to run at 40 Mhz instead of 80Mhz) ‘File: ConstantBlinkRate.spin CON _xinfreq = 5_000_000 _clkmode = xtal1 + pll8x PUB LEDonOFF dira[20] := 1 repeat outa[20] := 1 waitcnt (clkfreq/2 + cnt) outa[20] := 0 Download the code and see if there is a change in the flash rate of the LED.

So what happened? 1. Did your flash rate remain the same? 2. What happens if you change the pll8x to pll4x or pll2x? Although an actual NUMBER can be used to replace the clkfreq command its use should be limited. clkfreq is used when PREDICTABLE DELAYS are essential! (This is very critical when you want an object to be used by another object!)