18
Over-view of Lab. 1 See the Lab. 1 web-site and the lecture notes for more details

Over-view of Lab. 1

Embed Size (px)

DESCRIPTION

Over-view of Lab. 1. See the Lab. 1 web-site and the lecture notes for more details. Radio controlled – voice activated robotic car “term” project. Set-up the processor to control the board A/D and D/A; allows capture and play-back sound. - PowerPoint PPT Presentation

Citation preview

Page 1: Over-view of Lab. 1

Over-view of Lab. 1

See the Lab. 1 web-site and the lecture notes for more details

Page 2: Over-view of Lab. 1

Radio controlled – voice activatedrobotic car “term” projectSet-up the processor to control the board A/D

and D/A; allows capture and play-back sound.Set-up the processor so that we can read

general purpose input lines (GPIO -- switches) so we send various different commands.

Use DSP part of Blackfin processor to run (canned – meaning provided) frequency analysis program to recognize voice commands

Use the analysis of the sounds to output control values to a radio transmitter and control the car.

2 /17

Page 3: Over-view of Lab. 1

3 /17

Main Code – pseudo code for the “voice controlled car”main( ) {

Launch the Analog Devices audio “echo” program – a background interrupt-driven task that is given to you – you will modify this code

InitFlashASM( ); // Activate the system Flash memory without // stopping audio program which uses the Flash interface too

InitializePFInterfaceASM( ); // Activate the Push-button controller

Launch “VDK multi-threads” to control various processes // The VDK O/S is provided as part of the VDSP IDE

Thread 1 – Store batches of sound for analysisThread 2 – Analyze previous stored sound for “commands”Thread 3 – Use previous commands to send commands to control the carThread 4 – Check evaluation buttons for “options”Thread 5 etc

Page 4: Over-view of Lab. 1

4 /17

Another possible project

We want to build a audio controllerAudio in captured using audio A/D (CODEC)Audio out generated using audio D/A (CODEC)Manipulate the sound qualityPush buttons to control audio controller

operations – e.g. graphics equalizerLED lights to display operation results and

sound volume level (dancing lights)

Page 5: Over-view of Lab. 1

5 /17

Main Code – pseudo code for the “audio controller”main( ) {

Launch the Analog Devices audio “echo” program – a background interrupt-driven task that is given to you – you will modify this code

InitFlashASM( ); // Activate the system Flash memory without stopping // the audio program which uses the Flash interface too

InitializePFInterfaceASM( ); // Activate the Push-button controller

Wait for button1 to be pressed and released (ReadButtonASM() ), then play the sound at half-volume.

Wait for button2 to be pressed and released, play the sound at normal volumeWhen button3 is pressed -- Generate the extremely fascinating (but

completely useless) dancing lights which change with the audio stream volume level

Wait for button4 to be pressed and released, quit the program (turn off the sound and stop the processor)

}

Page 6: Over-view of Lab. 1

6 /17

Lab. 1 – Key project interfacingMicrocontroller I/O demonstration Your group must come into the laboratory class prepared to be able

to demonstrate all of the following by the end of class period You will make use of some of the code developed during the

assignments. (Note assignments may be due AFTER the laboratory) Initialize the Flash LED display interface (so that it works) Write a value to the LED display Read, and use, a value stored in the LED display, so you can test that

you are getting the correct answer Initialize the push-button controller interface Read, and use, a value provided by the push-button controller. Demonstrate tests to show that these operations work as required

OPTIONAL “ENCM415 Project club” :- Each laboratory will provide you with enough interface information to get a component of the voice-activated radio control car to work – if you want to put in another couple of hours work writing the necessary C++ code to make the interfaces operate correctly.

Page 7: Over-view of Lab. 1

7 /17

Task – Does my ADSP-BF533 board work?Download audio-talk-through program

If you have not already done so, download and expand ENCM415Directory2007.zip file (used in assignment 1) so that you have the correct directory. structure and test driven development environment needed for Laboratory 1.

Download and expand the files in 07CPP_Talkthrough.zip into your AudioDemo directory.

Build an AudioDemo Blackfin project in your AudioDemo directory and add the (provided) files into the project -- compile and link.

Download the executable (.dxe) file onto the BF533 processor.

Hook up your CD or IPOD output to the CJ2 stereo input. Hook up your ear-phones to the CJ3 stereo output. Run the AudioDemo.dxe executable and check that the talk through

program is working.

This task demonstrated your ability to build VDSP Blackfin projects and run the code. The AudioDemo code (running in a thread environment) forms the basis of the (optional) voice-activate radio-controlled car project.

Page 8: Over-view of Lab. 1

Tasks

Basic Task – develop the LED interface Initialize the Flash memory using the Blackfin external bus

interface unit (EBIU) (ASM) Initialize the Flash memory controller of the Blackfin

Evaluation Board LED’s (ASM)

Task (mainly in C++) that use the LED interfaceDevelop a simple counter (in C++) and display value Write a C++ routine to write morse code values into an

arrayWrite a routine to transfer the morse code values to the

LED’s (first in C++, then ASM)homepage.ntlworld.com/dmitrismirnov/morse-tab1.JPG

8 /17

Page 9: Over-view of Lab. 1

9 /17

Task – Initialize the Programmable flag interface – 16 GPIO lines on the Blackfin

Warning – could burn out the Blackfin processor if done incorrectly

You need to set (store a known value to) a number of internal registers in the Blackfin processor core.Other processors need equivalent GPIO control methods

Most important registersFIO_DIR – Data DIRection – 0 for input ****FIO_INEN – INterface ENableFIO_FLAG_D – Programmable FLAG Data register

Page 10: Over-view of Lab. 1

10 /17

Why do you need to know how to do read (load) and write (store) on internal registers?

Flag Direction register (FIO_DIR) Used to determine if the PF bit is to be used for input or

output -- WARNING SMOKE POSSIBLE ISSUE Need to set pins PF11 to PF8 for input, leave all other pins

unchanged as they may in use by other “threads” (Later Labs)

Page 11: Over-view of Lab. 1

11 /17

Registers used to control PF pins

Flag Input Enable Register Only activate the pins you want to use (saves power in

telecommunications situation) Need to activate pins PF11 to PF8 for input, leave all other pins

unchanged

Page 12: Over-view of Lab. 1

12 /17

Registers used to control PF pins

Flag Data register (FIO_FLAG_D) Used to read the PF bits (1 or 0) Need to read pins PF11 to PF8, ignore all other pins values

Page 13: Over-view of Lab. 1

13 /17

Task – Setting up the programmable flag interface

Follow the instructions carefullyFIO_DIR – direction register – write 0’s to bits 8, 9, 10,

11 – leave other bits unchanged (READ/AND/WRITE operations)

FIO_INEN – input enable register – write 1’s to bits 8, 9, 10, 11 – leave other bits unchanged (READ/OR/WRITE operations)

Other GPIO registers write 0’s to bits 8, 9, 10, 11 – leave other bits unchanged (READ/AND/WRITE operations)

There is a test program that will enable you to check your code – provide a screen dump of test result.

Page 14: Over-view of Lab. 1

14 /17

Task – Read the switches on the front panelTransfer the information to the LEDs so you can

demonstrate correct operationsBuild Initialize_ProgrammableFlagsASM ( )

MUST HAVE 50 pin cable connected between logic board and Blackfin for the switch values to be read correctly – otherwise always reads “1”

Logic board power supply must be turned on (or will read 1 always)

What we could do – “Simple optical transmitter” Place a “light sensitive detector” in front of the LED on a “second”

station. Use the output of the detector as the input instead of the switch Capture the light code signals Print out the “morse” code transmissions on the screen of the “first”

station – very basic optical transmission

Page 15: Over-view of Lab. 1

15 /17

#include <defsBF533.h>

#include <macros.h>

.global _ReadGPIOFlags__Fv;

_ReadGPIOFlags__Fv:

// Make an address register “point” to

// the GPIO Flag register to read switches

P1.L = lo (FIO_FLAG_D);

P1.H = hi (FIO_FLAG_D);

// Read the “16” bit flag register value and return // the value for the C++ code to use

R0 = W[P1] (Z);_ReadGPIOFlags__Fv.END: RTS;

Must use W [ ] readsince the manual shows that FIO_FLAG_D register is 16-bits

Must use W[P1] (Z) zero-extend as this adds 16 zeros to the 16 bits from FIO_FLAG_D register to make 32-bits to place into R0

int ReadGPIOFlags( )

Page 16: Over-view of Lab. 1

16 /17

If we wanted to get fancy we could do the following to the Talkthrough program (Task 1)

WHILE button 1 is pressed – add a mute operation – transmit 0’s

WHILE button 2 is pressed – add a gargle operation – sometimes transmit 0’s

IF both pressed – then mute operation takes precedence

After release of buttons (either order) normal operation of that button

Page 17: Over-view of Lab. 1

17 /17

If we wanted to get fancy we could do the following to the Talkthrough program

Gargling operation Need to add a simple counter that increments by

1 every 1/44000 s (each time that an audio sample is obtained)

Use the counter to turn the sound off and on every ½ s

Gargling sound is produced.

For more details – see Lab. 1 from 2006. Note that some of the function names changed between 2006 and 2007

Page 18: Over-view of Lab. 1

18 /18

Task -- Tests

There will be software tests (E-TDD) to allow you to demonstrate that your code works correctly

Note there are test executables (.dxe) available to test out your equipmentThis code can be used to test the switches and the

LED interface on your board. SwitchToLED.dxe This is the final version of my code for the “fancy”

audio controller  DrSmithAudioController.dxe