Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Lab. 1 – Required Tasks. For more details – see the Lab. 1 web-site."— Presentation transcript:

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

2 2 /25 Laboratory 1 – Tasks 1.Download the C++ Talk-through program. Board check -- Check that you can hear the audio output 2.Develop and test the code for initializing the Flash Memory and writing to the LED’s Use the provided tests to check your code 3.Routine for initializing the PF GPIO lines (programmable flags) Use the provided tests to check your code 4.Develop the ReadProgrammableFlagsASM( ) to read the switches Use the provided tests to check your code 5.Develop the Morse code program in C++ and ASM

3 3 /25 Set up for Task 1 AUDIO-IN AUDIO-OUT

4 4 /25 Task 1 Download audio-talk-through program If you have not already done so, download and expand ENCM415Directory2007.zip file so that you have the correct directory. structure and test driven development environment needed for Laboratory 1 and Assignments1. ENCM415Directory2007.zip Download and expand the files in 07CPP_Talkthrough.zip into your AudioDemo directory.07CPP_Talkthrough.zip 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.

5 5 /25 Question What is a “talk-through program”? Clear example of applying the first two rules of assembly language programming Rule 1: If you have a choice – don’t use assembly code  It takes as much time (and SOST) to “design, code, review, test and maintain” one line of C++ code as it does assembly code, but one line of C++ often can do more Rule 2: If somebody has a working example, cannibalize it for your own work (if legal)

6 6 /25 The talk through program (C++) Prepare to run C++ code (before you get to main( )) Set up the EBIU External Bus Unit Use EBIU to initialize A/D and D/A SET UP the A/D and D/A interrupts while (1) { /* Wait for messages */ } ACTIVATE the A/D and D/A interrupts Every 1 / 44,000 s Store A/D register value (DMA) into memory Call ProcessDataCPP( ) or ProcessDataASM( ) Load memory (DMA) into D/A register Set messages and flags to main( ) main( ) ISR -- Interrupt Service Routine

7 7 /25 main( ) int main(void) { sysreg_write(reg_SYSCFG, 0x32); //Initialize System Configuration Register Init_EBIU(); Init_Flash(); Init1836(); Init_Sport0(); // Serial PORT Init_DMA(); Init_Sport_Interrupts(); Enable_DMA_Sport0(); // Serial PORT while (1) { /* */ } } The system prepares the processor to run C++ code (before you get to main( )) Set up the EBIU External Bus Unit Use EBIU to initialize A/D and D/A SET UP the A/D and D/A interrupts while (1) { /* Wait for messages */ } ACTIVATE the A/D and D/A interrupts

8 8 /25 ProcessDataCPP( ) #include "Talkthrough.h" extern volatile int iChannel0LeftIn, iChannel0LeftOut; void Process_DataCPP(void) { iChannel0LeftOut = iChannel0LeftIn; iChannel0RightOut = iChannel0RightIn; iChannel1LeftOut = iChannel1LeftIn; iChannel1RightOut = iChannel1RightIn; } TASK 1 – Download the Talkthrough program and check that it works Voice-activated radio-controlled car works by modifying the ProcessData( ) subroutine

9 9 /25 Building a voice activated radio controlled car -- 4 Threads at least SWITCHES ON FRONT PANEL “INPUT COMMANDS: PROGRAMMABLE FLAGS FIO_FLAG_D Register YOUR PROGRAM RUNNING ON THE BLACKFIN LED LIGHTS ON FRONT PANEL “CONTROLSIGNALS TO RF TRANS: LED-CONTROLREGISTER EBIU INTERFACE ProcessDataASM( ) subroutine A/D D/A Interrupt routine D/A EAR PHONES A/DVOICE int ReadSwitches( )void WriteLED(int )

10 10 /25 Set-up for “Laboratory 1” interfacing. “Make the switches work” 1.De-activate Visual DSP 2.Power down Blackfin 3.Connect power to “special Blackfin interface” connector 4.Connect 50-pin cable to logic-lab 5.Connect 50-pin cable to Blackfin 6.Power up logic lab. station 7.Power up Blackfin 8.Reactivate Visual DSP 9.Check that station works using “Lab. 1 test-executable”

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

12 12 /25 Special “power-connector” for Blackfin interface on logic lab. station Picture of the “power connector” taken with a camera with a finger-print on the lens. Check that has not been stolen. Extras in your lab. kit is needed (perhaps)

13 13 /25 Connect 50-pin cable to Blackfin

14 14 /25 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 – toggle switches and LEDs CHEK each lab. As fuses can just wear out

15 15 /25 Task – 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 – 1 for enabled FIO_FLAG_D – Programmable FLAG Data register

16 16 /25 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

17 17 /25 Write the Blackfin assembly language instruction(s) to load the address of the internal programmable flag FIO_DIR register into pointer register P1 – then SET the Blackfin PF lines to act as inputs #include P1.L = lo (FIO_DIR); P1.H = hi (FIO_DIR); // Check the requirements – need to have all input // Manual says “setting a line for input means setting FIO_DIR bit values to 0” R0 = 0; W[P1] = R0; // This changes “All pins” ssync; // Force Blackfin to do the write (store) operation NOW not later Making sure that the FIO_DIR is correct for LAB. 1 – NOTE may need to change for later labaoratories Design Error “Changes all pins

18 18 /25 P1.L = lo (FIO_DIR); // #include “knows” FIO_DIR value P1.H = hi (FIO_DIR); // R0 = 0; // DESIGN ERROR – changes all pins to 0 // W[P1] = R0; // This changes “All pins” // Correct approach – use an AND mask operation // Read the current value // Prepare the 32-bit mask with bits // 8 to 11 set to 1, other bits 0 // Complement operation // bits 8 to 11 are 0, other bits 1 // R3 bits = 0 for bits 8 to 11; // R3 bits = FIO_DIR bits otherwise // Restore FIO DIR with bits 8 to 11 set to 0, ssync; // Force Blackfin to do the write (store) NOW not later Setting FIO_DIR to zero for “ONLY” pins 8, 9, 10 and 11. Other pins unchanged

19 19 /25 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

20 20 /25 Write the Blackfin assembly language instruction(s) to load the address of the internal programmable flag FIO_INEN register into pointer register P1 – then ENABLE the Blackfin PF lines as inputs #include P1.L = lo (FIO_?????); P1.H = hi (FIO_?????); // Check the requirements – need to have all input // Manual says “setting a line for input means setting bit values to 0” R0 = 0x0F00; W[P1] = R0; // This changes “All pins” 8 to 11 ON (enable), others OFF ssync; // Force Blackfin to do the write (store) NOW not later Making sure that the FIO_INEN is correct for enable of pins 8 to 11 Design Error “Changes all pins

21 21 /25 P1.L = lo (FIO_???); // #include “knows” FIO_INEN value P1.H = hi (FIO_???); // R0 = 0x0F00; // DESIGN ERROR – changes all pins // W[P1] = R0; // This changes “All pins” // Correct approach – use an AND mask operation // Read the current value // Prepare the 32-bit mask with bits // 8 to 11 set to 1, other bits 0 // R3 bits = 1 for bits 8 to 11; // R3 bits = FIO_DIR bits otherwise // Restore FIO INEN with bits 8 to 11 set to 1, ssync; // Force Blackfin to do the write (store) NOW not later Setting FIO_INEN to one for “ONLY” pins 8, 9, 10 and 11. Other pins unchanged

22 22 /25 Registers used to control PF pins Flag Data register (FIO_FLAG_D)  Used to read the PF bits as an input -- (1 or 0)  Need to read pins PF11 to PF8, ignore all other pins values

23 23 /25 Task – Setting up the programmable flag interface Follow the instructions carefully FIO_DIR – direction register – write 0’s to bits 8 to 11 FIO_INEN – input enable register – write 1’s to bits 8, 9, 10, 11 Other registers “bits” leave “unchanged: There are 6 registers in total To provide a screen dump of the test result to show your code works  Use PRT-SCR button and then paste in.doc file.

24 24 /25 #include.global _ReadBlackfinGPIOFlags__Fv; _ReadBlackfinGPIOFlags__Fv LINK 16; P1.L = lo (FIO_FLAG_D); // could be P0 P1.H = hi (FIO_FLAG_D); R0 = W[P1] (Z); P0 = [FP + 4]; UNLINK; _ReadPBlackfinGPIOFlags__Fv; JUMP (P0); Must use W [ ] since 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 ReadBlackfinGPIOFlagsASM( )

25 25 /25 How to use int ReadBlackFinGPIOFlagsASM( ) int GPIO_setting = ReadBlackfinGPIOFlagsASM( ) ; SWITCHES ON FRONT PANEL PROGRAMMABLE FLAGS FIO_FLAG_D Register int ReadSwitches( ) (FIO_POLAR register = 0) All switches unpressed Binary Pattern in FIO_FLAG_D register B ????0000???????? All switches pressed Binary Pattern in FIO_FLAG_D register B ????1111???????? Binary ? Means – we don’t know what the answer is

26 26 /25 How to use int Read BlackfinGPIO FlagsASM( ) int GPIO_setting = ReadBlackfinGPIOFlagsASM( ) ; SWITCHES ON FRONT PANEL PROGRAMMABLE FLAGS FIO_FLAG_D Register int ReadSwitches( ) (FIO_POLAR register = 0) All switches unpressed Binary Pattern in FIO_FLAG_D register B XXXX0000XXXXXXXX All switches pressed Binary Pattern in FIO_FLAG_D register B XXXX1111XXXXXXXX Binary X Means – we don’t know what the answer is – and don’t care

27 27 /25 Echoing the switches to the LED Code in main( ) – written in C++ int main( ) { InitializeGPIOInterface( ); // Check Lab. 1 for “exact name needed” InitializeFlashLEDInterface( ); // Check Lab. 1 for “exact name needed” #define SWITCHBITS 0x0F00 // Look in MIPs notes about // using a mask and the // AND bit-wise operation // to select “desired bits” while (1) { // Forever loop int GPIO_value = ReadBlackfinGPIOFlagsASM ( ); int desired_bits = GPIO_value & SWITCHBITS; int LED_light_values = desired_bits >> 8; // Bits in wrong position WriteFlashLEDLights(LED_light_values); // to display on LEDS }

28 Avoid this common mistake Many seem to think that the switch routine returns 1 is SW1 is pressed, 2 if SW2 is pressed, 3 if SW3 is pressed. This is NOT correct as the switch routine has to be able to return 16 different values Value meaning SW1 pressed, SW2, SW3, SW4 not pressed (0x0100) Value meaning SW1 and SW4 pressed with SW2 and SW3 not pressed (0x0900) 28 /25

29 29 /25 Practice example -- Rewrite the code so that loop stops if all the switches are pressed at the same time int main( ) { InitializeSwitchInterface( ); // Check Lab. 1 for “exact name needed” InitializeLEDInterface( ); ???? #define SWITCHBITS 0x0F00 // Looking in MIPs notes about MASKS while (???? ) { // conditional loop int GPIO_value = Read ReadBlackfinGPIOFlagsASM ( ); int desired_bits = GPIO_value & SWITCHBITS; int LED_light_values = desired_bits >> 8; // Bits in wrong position WriteFlashLEDLightsASM(LED_light_values); ???? }

30 30 /25 Laboratory 1 – Tasks 1.Download the C++ Talk-through program. Board check -- Check that you can hear the audio output 2.Develop and test the code for initializing the Flash Memory and writing to the LED’s Use the provided tests to check your code 3.Routine for initializing the PF GPIO lines (programmable flags) Use the provided tests to check your code 4.Develop the ReadProgrammableFlagsASM( ) to read the switches Use the provided tests to check your code 5.Develop the Morse code program in C++ and ASM


Download ppt "Lab. 1 – Required Tasks. For more details – see the Lab. 1 web-site."

Similar presentations


Ads by Google