Lab. 1 - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Lab. 1

Description:

... Download the Talkthrough program and check that it works Voice-activated radio ... code works Use PRT-SCR button and then paste in ... light _values = desired ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 31
Provided by: uca97
Category:
Tags: activated | lab | light

less

Transcript and Presenter's Notes

Title: Lab. 1


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

2
Laboratory 1 Tasks
  • Download the C Talk-through program.
  • Board check -- Check that you can hear the audio
    output
  • Develop and test the code for initializing the
    Flash Memory and writing to the LEDs
  • Use the provided tests to check your code
  • Routine for initializing the PF GPIO lines
    (programmable flags)
  • Use the provided tests to check your code
  • Develop the ReadProgrammableFlagsASM( ) to read
    the switches
  • Use the provided tests to check your code
  • Develop the Read-and-Store switch values in C
    and ASM use to drive the car

3
Set up for Task 1
AUDIO-IN
AUDIO-OUT
4
Task 1Download audio-talk-through program
  • If you have not already done so, download and
    expand ENCM511Directory.zip file so that you have
    the correct directory. structure and test driven
    development environment needed for Laboratory 1
    and Assignments1.
  • Download and expand the files in
    CPP_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.

5
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 dont 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
The talk through program (C)
Prepare to run C code (before you get to main(
))
Every1 / 44,000 s
Set up the EBIUExternal Bus Unit
Store A/D register value(DMA) into memory
Use EBIUto initialize A/D and D/A
Call ProcessDataCPP( )or ProcessDataASM( )
SET UP theA/D and D/A interrupts
Set messages and flagsto main( )
ACTIVATE the A/D and D/A interrupts
Load memory (DMA) into D/A register
while (1) / Wait for messages /
main( )
ISR -- Interrupt Service Routine
7
main( )
The system prepares theprocessor to run C
code(before you get to 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() Enabl
e_DMA_Sport0() // Serial PORT
while (1) / /
Set up the EBIUExternal Bus Unit
Use EBIUto initialize A/D and D/A
SET UP theA/D and D/A interrupts
ACTIVATE the A/D and D/A interrupts
while (1) / Wait for messages /
8
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
Building a voice activated radio controlled car
-- 4 Threads at least
SWITCHES ON FRONT PANELINPUT COMMANDS
LED LIGHTS ON FRONT PANELCONTROLSIGNALS TO RF
TRANS
PROGRAMMABLE FLAGS
LED-CONTROLREGISTER
FIO_FLAG_D Register
EBIU INTERFACE
YOUR PROGRAM RUNNING ON THE BLACKFIN
int ReadSwitches( )
void WriteLED(int )
ProcessDataASM( ) subroutine
D/A
EARPHONES
A/D
VOICE
A/D D/A Interrupt routine
10
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
Special power-connector for Blackfin interface
on logic lab. station
12
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
Connect 50-pin cable to Blackfin
14
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
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
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
Making sure that the FIO_DIR is correct for LAB.
1 NOTE may need to change for later
labaoratories
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 ltdefsBF533.hgt include ltmacros.hgt 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 WP1 R0 // This changes All pins ssync // Force Blackfin to do the write (store) operation NOW not later
Design Error Changes all pins
18
Setting FIO_DIR to zero for ONLY pins 8, 9, 10
and 11. Other pins unchanged
P1.L lo (FIO_DIR) // include ltdefsBF533.hgt knows FIO_DIR value P1.H hi (FIO_DIR) // R0 0 // DESIGN ERROR changes all pins to 0 // WP1 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

19
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
Making sure that the FIO_INEN is correct for
enable of pins 8 to 11
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 ltdefsBF533.hgt include ltmacros.hgt 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 WP1 R0 // This changes All pins 8 to 11 ON (enable), others OFF ssync // Force Blackfin to do the write (store) NOW not later
Design Error Changes all pins
21
Setting FIO_INEN to one for ONLY pins 8, 9, 10
and 11. Other pins unchanged
P1.L lo (FIO_???) // include ltdefsBF533.hgt knows FIO_INEN value P1.H hi (FIO_???) // R0 0x0F00 // DESIGN ERROR changes all pins // WP1 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

22
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
Task Setting up the programmable flag interface
  • Follow the instructions carefully
  • FIO_DIR direction register write 0s to bits
    8 to 11
  • FIO_INEN input enable register write 1s 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
int ReadBlackfinGPIOFlagsASM( )
include ltdefsBF533.hgt include ltmacros.hgt .global _ReadBlackfinGPIOFlags__Fv _ReadBlackfinGPIOFlags__Fv LINK 16 P1.L lo (FIO_FLAG_D) // could be P0 P1.H hi (FIO_FLAG_D) R0 WP1 (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 WP1 (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
25
How to use int ReadBlackFinGPIOFlagsASM( )
  • int GPIO_setting ReadBlackfinGPIOFlags
    ASM( )

(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????????
SWITCHES ON FRONT PANEL
PROGRAMMABLE FLAGS
FIO_FLAG_D Register
int ReadSwitches( )
Binary ? Means we dont know what the answer is
26
How to use int ReadBlackfinGPIOFlagsASM( )
  • int GPIO_setting ReadBlackfinGPIOFlagsAS
    M( )

(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
SWITCHES ON FRONT PANEL
PROGRAMMABLE FLAGS
FIO_FLAG_D Register
int ReadSwitches( )
Binary X Means we dont know what the answer is
and dont care
27
Echoing the switches to the LEDCode in main( )
written in C
int main( ) InitializeGPIOInterface( ) //
Check Lab. 1 for exact name needed InitializeFl
ashLEDInterface( ) // 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 gtgt 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 if 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)

29
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 gtgt 8 // Bits
in wrong position
WriteFlashLEDLightsASM(LED_light_values)
????
30
Laboratory 1 Tasks
  • Download the C Talk-through program.
  • Board check -- Check that you can hear the audio
    output
  • Develop and test the code for initializing the
    Flash Memory and writing to the LEDs
  • Use the provided tests to check your code
  • Routine for initializing the PF GPIO lines
    (programmable flags)
  • Use the provided tests to check your code
  • Develop the ReadProgrammableFlagsASM( ) to read
    the switches
  • Use the provided tests to check your code
  • Develop the Morse code program in C and ASM
Write a Comment
User Comments (0)
About PowerShow.com