Chapter 7 - Performance Understanding the PIC32 Clock and learning to optimize the memory interface for maximum performance.

Slides:



Advertisements
Similar presentations
MICROPROCESSORS AND MICROCONTROLLERS
Advertisements

Chapter 2 Walking in Circles Programming Loops in C.
Chapter 4 NUMB3RS.
Chapter 4 - NUMB3RS Learning to chose the right “types” Exploring The PIC32 - Lucio Di Jasio.
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
Microcontroller Programming II MP6-1
ECE 2211 Microprocessor and Interfacing Chapter 8 The 8088/8086 Microprocessors and their memory and I/O interfaces Br. Athaur Rahman Bin Najeeb Room.
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Chapter 11 It’s an Analog World Learning to use the Analog to Digital Converter.
Introduction of Holtek HT-46 series MCU
Embedded Systems Lecture 7: Configuration & memory Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
1 Lecture 6 Performance Measurement and Improvement.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Smarter systems and the PIC® 18FXX2 Chapter One 12.1 – 12.5 Dr. Gheith Abandah1.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – System Control Refer to Chapter 6 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Chapter 8 Communication Introduction to serial communication interfaces. Examples of use of the SPI module.
NS Training Hardware. System Controller Module.
The 8051 Microcontroller architecture
3-1 System peripherals & Bus Structure Memory map of the LPC2300 device is one contiguous 32-bit address range. However, the device itself is made up of.
Chapter 12 Capturing Input. Di Jasio - Programming 32-bit Microcontrollers in C Button Inputs.
Chapter 1 The First Flight Creating the first project and saying “Hello to the World”
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
Chapter 3 More Loops. Di Jasio – Programming 16-bit Microcontrollers in C (Second Edition) Checklist The following tools will be used in this lesson:
© AJH 2013, V2.0 Computer Programming Embedded Systems Programming Stand-alone code, system initialisation, operating systems. Low-level operations; port.
LPC2148 Programming Using BLUEBOARD
M Semiconductor Products Sector Computer Operating Properly Module Detail Slide #1 of 7 Tutorial Introduction PURPOSE -To explain how to configure and.
Chapter 2 A Loop in the Pattern Designing the Main Loop and Timing.
Chapter 4 TIMER OPERATION
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
Designing with Components Wilmer Arellano. How to chose a Microcontroller Choose one that you are familiar with or that is easy to learn.
C Examples 5. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
EEE527 Embedded Systems Lecture 5: Chapter 6 and7 Configuration & memory Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring
EEE527 Embedded Systems Lecture 2: Chapter 2: C and Using more MPLAB (X) + XC32 Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
I NTRODUCTION TO PIC PROGRAMMING By : S HERIF H ARHASH.
Chapter 5 - Interrupts.
The Silicon Laboratories C8051F020
Chapter Microcontroller
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
Computer Operating Properly Module MTT COMPUTER OPERATING PROPERLY MODULE (COP)
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Chapter 1 The Adventure Begins
Refer to Chapter 5 in the reference book
Microprocessor Systems Design I
Microprocessor Systems Design I
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
8086/8088 Hardware Specifications
Subject Name: Microcontroller Subject Code: 10ES42
AT91 Memory Interface This training module describes the External Bus Interface (EBI), which generatesthe signals that control the access to the external.
전자의료시스템 및 실습 System Configuration/Interrupt
EECE.3170 Microprocessor Systems Design I
8051 Micro Controller.
Example 18 Pulse Train Using Interrupts
EECE.3170 Microprocessor Systems Design I
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Week2.
ADSP 21065L.
Presentation transcript:

Chapter 7 - Performance Understanding the PIC32 Clock and learning to optimize the memory interface for maximum performance

Di Jasio - Programming 32-bit Microcontrollers in C PIC32MX3xx Clock Module

Di Jasio - Programming 32-bit Microcontrollers in C The OSCCON register

Di Jasio - Programming 32-bit Microcontrollers in C Primary Oscillator Clock Chain Input Divider Input Divider PLL Output Divider Output Divider 4 MHz72 MHz8 MHz 1 : 21 x 181 : 1 System Clock 72 MHz

Di Jasio - Programming 32-bit Microcontrollers in C PIC32MX3xx Configuration Settings #pragma config POSCMOD=XT, FNOSC=PRIPLL #pragma config FPLLIDIV=DIV_2, FPLLMUL=MUL_18, FPLLODIV=DIV_1 #pragma config FPBDIV=DIV_2, FWDTEN=OFF, CP=OFF, BWP=OFF NOTE: All PIC32MX devices are currently released to operate at frequencies up to 80 MHz. FPLLMUL = MUL_20 gives the required multiplier.

Di Jasio - Programming 32-bit Microcontrollers in C Fast Fourier Transform // input vector unsigned char inB[N_FFT]; // input complex vector float xr[N_FFT]; float xi[N_FFT]; // Fast Fourier Transformation void FFT( void) { int m, k, i, j; float a,b,c,d,wwr,wwi,pr,pi; // FFT loop m = N_FFT/2; j = 0; while( m > 0) { /* log(N) cycle */ k = 0; while( k < N_FFT) { // batterflies loop for( i=0; i<m; i++) { // batterfly a = xr[i+k]; b = xi[i+k]; c = xr[i+k+m]; d = xi[i+k+m]; wwr = wr[i<<j]; wwi = wi[i<<j]; pr = a-c; pi = b-d; xr[i+k] = a + c; xi[i+k] = b + d; xr[i+k+m] = pr * wwr - pi * wwi; xi[i+k+m] = pr * wwi + pi * wwr; } // for i k += m<<1 ; } // while k m >>= 1; j++; } // while m } // FFT

Di Jasio - Programming 32-bit Microcontrollers in C Windowing // apply Hann window to input vector void windowFFT( unsigned char *s) { int i; float *xrp, *xip, *wwp; // apply window to input signal xrp=xr; xip=xi; wwp=ww; for( i=0; i<N_FFT; i++) { *xrp++ = (*s ) * (*wwp++); *xip++ = 0; } // for i } // windowFFT

Di Jasio - Programming 32-bit Microcontrollers in C Computing Power and Scaling void powerScale( unsigned char *r) { int i, j; float t, max; float xrp, xip; // compute signal power (in place) and find maximum max = 0; for( i=0; i<N_FFT/2; i++) { j = rev[ i]; xrp = xr[ j]; xip = xi[ j]; t = xrp*xrp + xip*xip; xr[ j]=t; if ( t > max) max = t; } // bit reversal, scaling of output vector as unsigned char max = 255.0/max; for( i=0; i<N_FFT/2; i++) { t = xr[ rev[i]] * max; *r++ = t; } } // powerScale

Di Jasio - Programming 32-bit Microcontrollers in C Initialization // input vector unsigned char inB[N_FFT]; volatile int inCount; // rotation vectors float wr[N_FFT/2]; float wi[N_FFT/2]; // bit reversal vector short rev[N_FFT/2]; // window float ww[N_FFT]; void initFFT( void) { int i, m, t, k; float *wwp; for(i=0; i<N_FFT/2; i++) { // rotations wr[i] = cos(PI2N * i); wi[i] = sin(PI2N * i); // bit reversal t = i; m = 0; k = N_FFT-1; while (k>0) { m = (m << 1) + (t & 1); t = t >> 1; k = k >> 1; } rev[i] = m; } // for i // initialize Hanning window vector for( wwp=ww, i=0; i<N_FFT; i++) *wwp++ = * cos(PI2N * i); } // initFFT

Di Jasio - Programming 32-bit Microcontrollers in C “FFT.h” /* ** FFT.h ** ** power of two optimized algorithm */ #include #define N_FFT 256 // samples must be power of 2 #define PI2N 2 * M_PI / N_FFT extern unsigned char inB[]; extern volatile int inCount; // preparation of the rotation vectors void initFFT( void); // input window void windowFFT( unsigned char *source); // fast fourier transform void FFT( void); // compute power and scale output void powerScale( unsigned char *dest);

Di Jasio - Programming 32-bit Microcontrollers in C The Running Project /* ** Run.c ** */ // configuration bit settings #pragma config POSCMOD=XT, FNOSC=PRIPLL #pragma config FPLLIDIV=DIV_2, FPLLMUL=MUL_18, FPLLODIV=DIV_1 #pragma config FWDTEN=OFF, CP=OFF, BWP=OFF #include #include "fft.h“ main() { int i, t; double f; // 1. initializations initFFT(); // test sinusoid for (i=0; i<N_FFT; i++) { f = sin(2 * PI2N * i ); inB[ i] = ( unsigned char) (120.0 * f); } // for // 2. perform FFT algorithm windowFFT( inB); FFT(); powerScale( inB); // 3. infinite loop while( 1); } // main

Di Jasio - Programming 32-bit Microcontrollers in C Capturing Time // init 32-bit timer4/5 OpenTimer45( T4_ON | T4_SOURCE_INT, 0); // clear the 32-bit timer count WriteTimer45( 0); // insert FFT function calls here // read the timer count t = ReadTimer45();

Di Jasio - Programming 32-bit Microcontrollers in C The CHECON Register

Di Jasio - Programming 32-bit Microcontrollers in C Optimizing WaitStates SYSTEMConfigWaitStatesAndPB( L);

Di Jasio - Programming 32-bit Microcontrollers in C Turning the Cache ON SYSTEMConfigWaitStatesAndPB( L); CheKseg0CacheOn();

Di Jasio - Programming 32-bit Microcontrollers in C Enabling Pre-Fetch SYSTEMConfigWaitStatesAndPB( L); CheKseg0CacheOn(); mCheConfigure( CHECON | 0x30);

Di Jasio - Programming 32-bit Microcontrollers in C Remove RAM Wait States // configure PB frequency and the number of wait states SYSTEMConfigWaitStatesAndPB( L); // enable the cache for max performance CheKseg0CacheOn(); // enable instruction prefetch mCheConfigure( CHECON | 0x30); // disable RAM wait states mBMXDisableDRMWaitState(); SYSTEMConfigPerformance( L);

Di Jasio - Programming 32-bit Microcontrollers in C Data Control & Monitor Interface

Di Jasio - Programming 32-bit Microcontrollers in C The FFT Output