“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

Data Dependencies Describes the normal situation that the data that instructions use depend upon the data created by other instructions, or data is stored.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
A look at interrupts What are interrupts and why are they needed.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 3 – New instruction recap Tutorial.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
Software and Hardware Circular Buffer Operations First presented in ENCM There are 3 earlier lectures that are useful for midterm review. M. R.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
Lab. 2 Overview 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have that knowledge?
A look at interrupts What are interrupts and why are they needed.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Blackfin BF533 EZ-KIT Control The O in I/O
HD44780 LCD programming From the Hardware Side
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 3 Understanding the memory pipeline issues.
Averaging Filter Comparing performance of C++ and ‘our’ ASM Example of program development on SHARC using C++ and assembly Planned for Tuesday 7 rd October.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM511.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 2 Understanding the pipeline.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system Manual control of RC car.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Lab. 2 Overview. Echo Switches to LED Lab1 Task 7 12/4/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 28.
1 ARM University Program Copyright © ARM Ltd 2013 Using Direct Memory Access to Improve Performance.
Mistakes, Errors and Defects. 12/7/2015Mistakes, Errors, Defects, Copyright M. Smith, ECE, University of Calgary, Canada 2 Basic Concepts  You are building.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
Assignment 4 / Lab. 3 Convert C++ ISR to ASM AND GET IT TO WORK Doing Assignment 4 / Lab. 3 the Test Driven Development way.
Developing Tasks to use with a co-operative scheduler Ideas for Assignment 2 Lab. 2, 3 and 4 Review for Midterm on Lab. 2 Ideas of defects, errors and.
Computer Architecture
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Software and Hardware Circular Buffer Operations
Generating “Rectify( )”
A Play Core Timer Interrupts
Thermal arm-wrestling
Trying to avoid pipeline delays
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Lab. 2 – More details – Later tasks
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Thermal arm-wrestling
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
A Play Lab. 2 Task 8 Core Timer Interrupts
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
HD44780 LCD programming From the Hardware Side
HD44780 LCD programming From the Hardware Side
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Explaining issues with DCremoval( )
Lab. 4 – Part 2 Demonstrating and understanding multi-processor boot
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Independent timers build into the processor
Thermal arm-wrestling
Mistakes, Errors and Defects
Post Lab Quiz 3 Review Assignment 2 Help
Working with the Compute Block
A first attempt at learning about optimizing the TigerSHARC code
Presentation transcript:

“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved, by using DMA to send out SPI signals

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 30 Transfer array using “normal array handling” Normal code P0  address of start_array[0]; P1  address of final_array[0]; SPI -- point to SPI_TDBR R0  max-value needed to transfer When SPI ready -- do transfer R1  How many values already transferred Even more processor waiting R1 = 0; LOOP: CC = R0 <= R1 IF CC JUMP DONE: R2 = [P0++]; VERY BIG PIPELINE [P1++] = R2; LATENCY ISSUES JUMP LOOP; MANY INTERNAL PROCESSOR STALLS DONE: WHILE WAIT FOR R2 TO BE Do something else READ, STORED and then TRANSMITTED

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 3 / 30 Concept of a basis MEMDMA and SPI DMA task DMA DMA_source_address_register  address of start_array[0]; DMA_destination_address_register  address of final_array[0]; DMA_max_count_register  max-value needed to transfer DMA_count_register  How many values already transferred R1 = 0; SPI destination is SPI_TDBR LOOP: DMA hardware must “know” how to wait CC = R0 <= R1 until SPI hardware is ready IF CC JUMP DONE: R2 = [P0++]; DMA_enable = true [P1++] = R2; Miminized pipeline issues JUMP LOOP; DONE: Do something else Processor can do something else while DMA is working

Chapter 9 of the Blackfin Hardware book 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 4 / 30

Design expected functionality of simple MEMDMA task #define NUMPTS 1024 section (“SDRAM”) int destArray[NUMPTS]; int sourceArray[NUMPTS]; TEST(simpleDMAtask) { Set_ArrayZero(destArray); Set_KnownValues(sourceArray); DoMEMDMATransfer(sourceArray, destArray, NUMPTS ); CHECK_ARRAY_EQUAL(sourceArray, destArray, NUMPTS ): …. Other tests here …. } 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 5 / 30

DMA registers we need to worry about 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 6 / 30 Final exam question ideas Other test examples Did the hardware think it transferred all the required values? CHECK(NUMPTS, *pMDMA_S0_CURR_X_COUNT); CHECK(NUMPTS, *pMDMA_D0_CURR_X_COUNT);

Actual code 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 7 / 30 Not good as final code in a program as involves a wait

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 8 / 30 Source DMA – read Destination DMA – write

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 9 / 30 DMA register detail -- status RO W1C bits Why only Destination DMA status considered?

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 10 / 30

Final test result 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 11 / 30 Placing array in external memory

Why the failures? 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 12 / 30 X_COUNT = 0. Perhaps this register only useful when doing DMA (how much done before error occurred) – not useful when done What one line did I change to fix code?

Try the same with SPI DMA 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 13 / 30 Essentially identical code to InitSPI( ) before (Lab3)

Design the tests to check if working 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 14 / 30

Concept correct – implementation wrong 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 15 / 30 The book says there is only one channel for non-memory DMA

Would this work We can change *pMDMA_S0_START_ADDR to *pDMA0_START_ADDR perhaps but how handle the SPI destination? 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 16 / 30

Use some ideas from Lab. 2 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 17 / 30 Specific DMA channel for SPI? This tells us Channel 5 dedicated to SPI register_handler(ik_ivg10,…. IMASK |= 0x Something new if we “make mistakes”

First attempt at the code 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 18 / 30 Just guessed at the DMA register names based on earlier code Need to check the bit positions

3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 19 / 30 Need to check the bit usage on CONFIG and STATUS registers

Second attempt at the code 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 20 / 30 Final exam hint Common error in the lab. Why did it happen? How do you fix?

Code “hangs” – where you might expect it to hang Final exam debug question – How would you determine if the code got into ISR and perhaps is now hanging there? Answer never got to the ISR – if “infinite loop” in ISR then would not be showing the “infinite loop” here 3/13/2016DMA (repeating code), Copyright M. Smith, ECE, University of Calgary, Canada 21 / 30

Is the DMA channel running at all? Set break point to check 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 22 / 30 IMASK set Transferred 1 SPI_TDBR = 0

Based on debug information IMASK is set correctly We transferred 1 “something” Is direction correct? Final Exam hint on testing sourceArray[0] is being set to 0 as first thing to transfer to SPI SPI_TDBR has reset value is 0 Which of the two zeros are we seeing? Need better array values to use during testing 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 23 / 30

Run again after fixing test *pSPI_TDBR = 0x100 This is not the reset value (0) so correct DMA transfer did occur From Lab. 2 – is SIC_IMASK correct? 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 24 / 30 I also see that the DMA interrupts are not set Previous Memory DMA code set interrupt on MDMA_D0 channel – which we now don’t use.

Set DMA Interrupt bit Check SIC_IMASK Setting 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 25 / 30

Check SIC_IMASK setting *pSIC_IMASK |= 0x /13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 26 / 30

With SIC_IMASK fixed We go immediately into ISR Still to know When did interrupt occur (at what line of code)? Does interrupt clear? Set break point at StartSPIDMA( ) and then step through code to find out (F11) 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 27 / 30

Single step results Problem occurs “before we start DMA” And we never get out of ISR 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 28 / 30

Trying starting SPI after DMA 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 29 / 30

First transfer is correct None of the others Only ever transfers the “first” element of sourceArray 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 30 / 30 Hangs here when doing line 92Since hanges second time around loop

Since hangs inside SetupSPIDMA “2 nd ” time around 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 31 / 30

Test to transfer many First test works Second test -- Hangs again Try stopping and restarting SPI and DMA 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 32 / 30 Final exam hint Nasty Code defect here

Why does the first test fail and the second test pass? 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 33 / 30

Final exam answer would need understanding of what a FIFO is. 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 34 / 30

Test Driven Development Next stage We wrote the tests Wrote code to satisfy the tests Modified the tests “Code” just runs Sometimes test fails first time but passes second time – indication of a “race” condition (SPI_BAUD transfer rate slower than Blackfin?) We now need to keep the tests and REFACTOR the code to make more use-able With TTCOS (Lab. 3) need to make run without interrupts. 3/13/2016DMA, Copyright M. Smith, ECE, University of Calgary, Canada 35 / 30