Later tasks of Lab. 1

25
Later tasks of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab. session

description

Later tasks of Lab. 1. For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab. session. Print out the Lab. 1 web-pages for use as reference during the lab. period. - PowerPoint PPT Presentation

Transcript of Later tasks of Lab. 1

Page 1: Later tasks of Lab. 1

Later tasks of Lab. 1

For more details – see the Lab. 1 web-site

There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab. session

Page 2: Later tasks of Lab. 1

2 /27

Print out the Lab. 1 web-pages for use as reference during the lab. period

There will be a short 15-minute in-class quiz at the start of the lab. period – don’t be late

Quiz will be based on knowledge demonstrated during assignments 1 and 2

Page 3: Later tasks of Lab. 1

3 /27

Task 1Download audio-talk-through program If you have not already done so, download and expand

ENCM415Directory.zip file so that you have the correct directory. structure and test driven development environment needed for Laboratory 1.

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

Add the CPP_Talkthrough project in your Lab. 1  directory to the VisualDSP environment -- 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 CPP_Talkthrough.dxe executable and check that the talk

through program is working.

Page 4: Later tasks of Lab. 1

4 /27

Task 2 -- Convert ProcessDataCPP( ) to ProcessDataASM () – Assign. 2 Q3 In talkthrough.h. add a prototype for your assembly code function

Process_DataASM;

In ISR.cpp change to

// call function that contains user code#if 0      Process_DataCPP();  // Use the C++ version#else     Process_DataASM(); // C assembly code routines especially developed for Lab. 1#endif 

Right-click on ProcessDataCPP.cpp entry. Use "FILE OPTIONS“ to exclude linking

Use PROJECT | clean project Add your ProcessDataASM.asm file to the project, recompile and link.

Check that your code works More details on the Lab. 1 web pages

Page 5: Later tasks of Lab. 1

5 /27

Set up for Tasks 1 and Task 2

AUDIO-IN

AUDIO-OUT

Page 6: Later tasks of Lab. 1

6 /27

How we are building the volume controller

SWITCHES ON FRONT PANEL

PROGRAMMABLE FLAGS

FIO_FLAG_D Register

YOUR PROGRAM RUNNING ON THE BLACKFIN

LED LIGHTS ON FRONT PANEL

LED-CONTROLREGISTER

EBIU INTERFACE

ProcessDataASM( ) subroutine

A/D D/A Interrupt routine D/AEAR

PHONESA/D

IPODCD

int ReadSwitches( ) void WriteLED(int )

Page 7: Later tasks of Lab. 1

7 /27

Special “power-connector” for Blackfin interface on logic lab. station

Page 8: Later tasks of Lab. 1

8 /27

Special “power-connector” for Blackfin interface on logic lab. station

Page 9: Later tasks of Lab. 1

9 /27

Connect 50-pin cable to Blackfin

Page 10: Later tasks of Lab. 1

10 /27

Connect 50-pin cable to logic lab

Make sure that all 50-pin connections are secure and proper.

Power up the logic lab. station and check that is working

Page 11: Later tasks of Lab. 1

11 /27

Task 3 – Initialize the Programmable flag interface – 16 I/O 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 Blackfin internal registers

Most important ones FIO_DIR – Data DIRection – 0 for input **** FIO_INEN – INterface ENable FIO_FLAG_D – Programmable FLAG Data register

Page 12: Later tasks of Lab. 1

12 /27

Task 4 – Demonstration stream

Final laboratory requirements

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

Wait for button2 (SW2 – PF9) to be pressed and released, play the sound at normal volume

Each time button3 (SW3 – PF10) is pressed and released, transfer a known value from an array to the LED display (WriteLEDASM( ) ) and check that the expected value is displayed (ReadLEDASM( ) )

Wait for button4 t (SW4 – PF11) o be pressed and released, quit the program (turn off the sound and stop the processor)

Build Initialize_ProgrammableFlagsASM ( ) Modify main( ) and ProcessDataASM( ) so that button-operation and

volume operation works MUST HAVE 50 pin cable connected between logic board and

Blackfin Logic board power supply must be turned on

Page 13: Later tasks of Lab. 1

13 /27

Task 4 – Application stream

Final laboratory requirements

SW1 connected to PF8 -- Mute button (This task) SW2 connected to PF9 -- Gargle button (Task 5) SW3 connected to PF10 -- Volume up (Task 7) SW4 connected to PF11 -- Volume down (Task 7)

Build Initialize_ProgrammableFlagsASM ( ) Modify main( ) and ProcessDataASM( ) so that MUTE-operation

works MUST HAVE 50 pin cable connected between logic board and

Blackfin Logic board power supply must be turned on

Page 14: Later tasks of Lab. 1

14 /27

Task – Gargling operation – Application stream Need to add a simple counter that increments by 1 every

1/44000 s

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

Gargling sound is produced. You need to have a signed demo sheet from a 2nd or 4th

year student. Bonus if not from department Plan ahead – remember that mute button overrides

gargle operation

Page 15: Later tasks of Lab. 1

15 /27

Gargle and Mute – Application stream

int main( ) {

InitializeSwitchInterface( ); // Check Lab. 1 for “exact name needed”InitializeLEDInterface( );

#define SWITCHBITS 0x0F00 // Looking in MIPs notes about // using a mask and the // AND bit-wise operation

// to select “desired bits” while (1) { // Forever loop int switch_value = ReadProgrammableFlagsASM( );

// if switch 1 is on – set volatile mute_on = 1; // other wise set mute_on = 0;

// Variables used by modified ProcessSoundASM()

// if switch 2 is on – set volatile cause_gargle = 1; // other wise set cause_gargle = 0

}

}

Page 16: Later tasks of Lab. 1

16 /27

Application stream Task code --- mute button

PSEUDO CODE

extern volatile boolean mute_on;

void Process_DataASM(void) { if (mute_on = = FALSE)

MakeTheSound( );}

WORRY ABOUT WHAT EX_INTERRUPT_HANDLER( ) MEANS IN LAB. 2

File “interruptservice.cpp”

extern volatile boolean mute_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff

Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;}

Page 17: Later tasks of Lab. 1

17 /27

Task code – Gargle – Application stream

void Process_DataASM(void) { if (mute_on = = FALSE)

if (gargle_on == 0)

MakeTheSound( );}

Some how we want to do the following

Is cause_gargle is true – no sound for ½ s and then sound for ½ s

Do this by changing gargle_on from 1 to 0 to 1 at ½ s intervals?

How? Will the code ALWAYS still work after “both buttons” are released, only work 50% of the time

WORRY ABOUT WHAT EX_INTERRUPT_HANDLER( ) MEANS IN LAB. 2

File “interruptservice.cpp”

extern volatile boolean mute_on;extern volatile boolean cause_gargle;extern volatile int gargle_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;}

Page 18: Later tasks of Lab. 1

18 /27

Profound Procrastination Programming – Application stream

File “interruptservice.cpp”

extern volatile boolean mute_on;extern volatile boolean cause_gargle;extern volatile int gargle_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff

if (cause_gargle == TRUE) TurnGargleOnThenOff( )else gargle_on = 0;

Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;}

WORRY ABOUT WHAT EX_INTERRUPT_HANDLER( ) MEANS IN LAB. 2

File “interruptservice.cpp”

extern volatile boolean mute_on;extern volatile boolean cause_gargle;extern volatile int gargle_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;}

Page 19: Later tasks of Lab. 1

19 /27

Profound Procrastination Programming – Application stream

File “interruptservice.cpp”

extern volatile boolean mute_on;extern volatile boolean cause_gargle;extern volatile int gargle_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff

if (cause_gargle == TRUE) TurnGargleOnThenOff( )else gargle_on = 0;

Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;}

WORRY ABOUT WHAT EX_INTERRUPT_HANDLER( ) MEANS IN LAB. 2

This interrupt routine is executed every 1 / 44000 s

For 22000 of those times we want gargle_on

For the next 220 of those times we want the gargle off

So we develop a counter

Page 20: Later tasks of Lab. 1

20 /27

Profound Procrastination Programming – Application stream

File “interruptservice.cpp”

extern volatile boolean mute_on;extern volatile boolean cause_gargle;extern volatile int gargle_on;void Process_DataASM(void);

EX_INTERRUPT_HANDLER(Sport0_RX_ISR){

…….. /// Lots of good stuff

if (cause_gargle == TRUE) TurnGargleOnThenOff( )else gargle_on = 0;

Process_DataASM( ); // Make the sound occur

…….. // Lots of more good stuff;

}

WORRY ABOUT WHAT EX_INTERRUPT_HANDLER( ) MEANS IN LAB. 2

extern volatile int gargle_on;

void TurnGargleOnThenOff( ) {

static long int count = 0;

count = count + 1; if (count >= 22000) { count = 0;

gargle_on = 1 – gargle_on); } }

Check web-pages to see if TurnGargleOnThenOff( ) is to be written in assembly code or in C++

Page 21: Later tasks of Lab. 1

21 /27

Task 6 – LED interface and Dancing Lights

LED interface setup code provided

Check that you can read switches and make the values appear on the LED

Then – writing in “C++” code (interfaced to your assembly code) – display the amplitude (absolute value) of the sound

Page 22: Later tasks of Lab. 1

22 /27

LED interface and Dancing Lights

LED interface setup code provided

Demo stream Transfer values from a known array to the LED

Application stream Writing in “C++” code (interfaced to your assembly

code) – display the amplitude (absolute value) of the sound – will need to store 32 values in an array and generate (running) average

Page 23: Later tasks of Lab. 1

23 /27

Solving Lab. 1 Task Dancing lights – Application stream

Many different ways – you and your partner work one out

One of the ways is to “call a C++ function” from inside your assembly code routine ProcessDataASM( ). How to do that was handled in Assignment 2

and also provided in detail on the web-pages

Page 24: Later tasks of Lab. 1

24 /27

Task Application stream – Volume control

Writing in C++, develop the final volume control

Note there are test codes available to test out your equipment

This 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 Lab. 1.  DrSmithLab1Final.dxe

Page 25: Later tasks of Lab. 1

25 /27

Information of the marks and what needs to be handed in Hand in at the start of the Thursday tutorial

Sec. 1 – 6th October Sec. 2 – 13th October (Same day as planned prelab. 2 quiz)

Note Lab.1 Section 1 is first session – Sept 26th Section 2 is second session – Oct. 3rd

THERE ARE NO LABS ON THE MONDAY OF THANKSGIVING

Note Lab. 2 Section 2 is first session – Oct. 17th

Section 1 is second session – Oct 24th