Multi-threaded projects Services and Drivers Alternate ways of doing Labs 1, 2, 3 and 4. ENCM415 – “Ideal” final project Plans for a “complete” Lab. 4 Run the audio input and output (Lab. 0) Reading the light sensor (Lab. 2) Reading the thermal sensor (Lab. 3) Displaying values in the Flash LED (Lab. 1) Displaying values on the external LCD screen over the SPI interface (Lab. 4) Using interrupts (Labs. 2, 3 and 4) Control that robot car (Lab. 17) and plane (Lab. 22000) Do-able with knowledge we already have Spend 40 hours to complete – is there a simpler way 3/18/2016 2 / 28 A simpler way Some teams prefer to use development approaches essentially equivalent to what we have done in Labs 1, 2 and 3 Becomes easier with practice, but does not come easy. Other teams are using “prepared” code from the manufacturer. Threads Services and Drivers Reliability issues “forcing” manufacturers to ensure “prepared code” works well 3/18/2016 3 / 28 Doing Lab. 4 project in industry We might not develop a final “.dxe” executable We might get each task to run by its self Then add each task as a “thread” inside a multithreaded operating system. The processor (using core timer interrupts) would automatically switch between tasks as each data became available Easier to integrate new Lab. with the previous labs Straight forward to do with Analog Devices VDK – Visual DSP Kernel, uCLinux, uC-OS etc etc 3/18/2016 4 / 28 Initialization Thread 3/18/2016 Main Thread – example While task “pends” (wait till ready), it automatically gets switched out of the processor 3/18/2016 Each Lab. 4 task has its own thread function which replaces the sleep 6 / 45 VDK History shows tasks switched out when they have to wait 3/18/2016 Concept of task priority 7 / 45 Would VDK make 415 easier NO, using VDK would make 415 harder as you have another interface to learn How do you debug a function (LED display) when the function works with one thread and not with another? Answer – with great difficulty But learning VDK would make the ENCM491 (real time) and ENCM515 (DSP architectures) easier to learn as you could cut 6 weeks out of each class because of the extra 6 weeks needed in ENCM415 (a saving of 6 weeks). 3/18/2016 8 / 28 Would threads make industry easier? PROBABLY NOT, using threads the first time makes the project harder, you have another interface to learn However “PROVIDED” the real-time operating system is “inexpensive” and “reliable” you have a common interface that many developers on your team can all use. Product is shorter time and lower cost However, many developers don’t want to use “commercial” OS as “too slow”, “too difficult to customize” for the product. They would rather use the techniques you have used in ENCM415. Also, using threads only changes about 20% of the code you have to develop. Basically all you have is better “while loops” and “easier semaphores” and”messaging” 3/18/2016 9 / 28 System Services Much of this presentation is based on Analog Devices on-line Blackfin training by David Lannigan at my.analog.com/onlinetraining/Static/BOLDList.html There are audio and video presentations on Blackfin® Device Drivers (May 2006) Blackfin System Services (Jan. 2006) Introduction to VDK (Sept. 2006) It is recommended that users have some understanding of the Blackfin architecture, basic knowledge of software terminology and experience in embedded systems. Meaning have taken ENCM415 3/18/2016 10 / 28 3/18/2016 11 / 28 Would system services help in ENCM415? For Labs. 1, 2 and 3 – No You have to know the sort of thing that is supposed to happen with the hardware in some very simple cases (Flash memory, GPIO, LEDs) How do you start an interrupt? How do you build an interrupt service routine? How can you build a fast ISR in assembly code? 3/18/2016 12 / 28 Would system services help in Lab. 4? System services provide you all the functions that you developed in Labs. 1, 2 and 3 for GPIO etc If the services are simple to learn how to use for GPIO control, then perhaps we can quickly get it to work for the SPI interface. Analog Devices has just recently updated their “services” software, so using services has potential 3/18/2016 13 / 28 Proposed Lab. 4 – Demo-based Demonstrate in class using services to do Labs. 1 and 2 50% -- Connect LCD screen to logic lab and switches. Place commands in an array. Manually (using switches) send commands to LCD screen to show “Happy 415 Christmas” 30% -- Demonstrate Lab. 4 Temperature and Light sensor using – You will need to add a modified “CalculateTemperature( )” from Lab. 3 and the PF9 service 20% -- Add a “SPI SERVICE” to transfer the commands from the Blackfin to the LCD 3/18/2016 14 / 28 All true, the third time you try using it However, that’s what you do in an industrial environment 3/18/2016 15 / 28 All the non-hardware stuff from Lab. 1, 2 and 3 stays the same VDK All the hardware stuff from Lab. 1, 2 and 3 – “better?” 3/18/2016 16 / 28 3/18/2016 17 / 28 Powerful – once we know how to use it 3/18/2016 18 / 28 Lots of new syntax to learn 3/18/2016 19 / 28 Something related to Lab. 2 3/18/2016 20 / 28 Some of these functions are recognizable 3/18/2016 21 / 28 3/18/2016 22 / 28 Interrupt handler hidden 3/18/2016 23 / 28 But there is much to learn 3/18/2016 24 / 28 Service for fast memory transfer 3/18/2016 25 / 28 3/18/2016 26 / 28 Sounds like Lab. 2 3/18/2016 27 / 28 3/18/2016 28 / 28 Many functions recognizable 3/18/2016 29 / 28 3/18/2016 30 / 28 Perhaps try for Lab. 4 3/18/2016 31 / 28