1 / 27

Getting the O in I/O to work on a typical microcontroller

Getting the O in I/O to work on a typical microcontroller. Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller used in Assignment 1 and the Familiarization Lab. Agenda.

emchugh
Download Presentation

Getting the O in I/O to work on a typical microcontroller

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting the O in I/O to workon a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controllerused in Assignment 1 and the Familiarization Lab

  2. Agenda • Processors need to send out control signals (high / low 1 / 0 true / false) • General Purpose Input / Output lines (GPIO lines) on Blackfin chip (16) • FLASH memory chip has additional I/O ports connected to Ez-Lite KIT LED’s • What do we need to have happen to make the FLASH memory work on a microcontroller as we want. (In this example turning the board LED’s on and off) • What new Blackfin assembly language instructions do we need to learn in order to operate the LEDs? Blackfin BF533 I/O

  3. Radio controlled car In principle we could • Connect the signal that controls the LED1 output directly to the turn-to-right signal line of radio transmitter • Connect the signal that controls the LED2 directly up to the go-forward signal line of radio transmitter • Connect LED3 control up to the turn-to-left signal line of radio transmitter • “IN PRINCIPLE” means – we might start off this way while we initially explore ideas to control the car. However we may (or may not) finish the project a different way. COULD USE LEDs AS A VIRTUAL CAR CONTROLLER Blackfin BF533 I/O

  4. Programmable Flags (input Lab) • Most micro-controllers have general purpose input or output lines capable of generating “true” or “false” values • Blackfin 533 has 16 GPIO lines Blackfin BF533 I/O

  5. Where are the GPIO pins found on the board? (Shared with video PPI controller) Blackfin BF533 I/O

  6. GPIO lines are very useful • They are used to sent control signals to many of the peripherals that are found on the Blackfin Evaluation Board. • Video Control – GPIO PF0 to PF7 • Audio Control -- ?? (Never looked) • Input -- Buttons – GPIO PF8, 9, 10, 11 • Output – GPIO PF0, PF1, PF5, PF6, PF7 • SPI interface control for LCD -- PF5 • SPI interface Haptic Control – PF6 • Pins are functionally multiplexed – MEANS pins can perform different functions at different times. Blackfin BF533 I/O

  7. Additional I/O pins available Blackfin BF533 I/O

  8. Used to control LED on board • Controlled using special “additional” parallel port interface attached to “flash” memory chip PROJECT USE LEDs used to INDICATEdirection radio-controlledcar will move. Not currently used to control the car (but could). LEFTRIGHTFORWARDBACK CONTROL ON Blackfin BF533 I/O

  9. FLASH MEMORY UNIT • Major task of this unit is to store the code need to “boot” (start) the processor 2 PSD4256G6V From STMicroElectronics The FLASH part we need during Lab. 1 Additional I/O pins Blackfin BF533 I/O

  10. LEDs connected to FLASH port BACKFORWARDRIGHTLEFTThese pins are controlling other things on the board DON’T CHANGE PB6_A, PB7_A BEHAVIOUR WHEN YOU CODE THE LED OPERATION(Use AND / OR instructions) Airplane falls from sky syndrome Blackfin BF533 I/O

  11. Steps to activating LEDs • Get the FLASH memory to work correctly (set many FLASH registers) • Write the code for InitFlashASM( ) • Get the FLASH I/O Port to work correctly as output for pins PB5  PB0, leaving other pins unchanged • Write the code for InitFlashPortASM( ) • Write the value we want to LEDs • WriteFlashLEDASM( int value) • Read back the value the LEDs show • int ReadFlashLEDASM( ) for testing Blackfin BF533 I/O

  12. FLASH MEMORY UNIT • Controlled through “EBIU”External Bus Interface UnitEBIU are common on most processors (although often by different name) FLASH OTHERPINSUSED WAIL! SDRAMCONTROLLER Blackfin BF533 I/O

  13. Key information about EBIU • Three busses come into the EBIU from the Blackfin processor core • Forwards data to SDRAM and FLASH • How does EBIU “know” whether data has to be send to FLASH unit (I/O)and which data to the SDRAM units (memory store)????? (Control logic question on quiz / exams) Blackfin BF533 I/O

  14. SDRAM and FLASH • In later laboratories • We will build a stand-alone microcontroller system, which means we will need to understand how to program the flash memory so that the processor “knows” what to do when powered-up. Common practice on processors for boot process reads start up code from FLASH • We will need to process “large arrays” – too large to fit into the “internal fast” Blackfin “L1” memory so they must be placed in SDRAM.Common practice on processors • In this laboratory, we need to program the “extra” FLASH chip I/O pins which are connected to the LED’s – control the lights now, perhaps control car later. Blackfin BF533 I/O

  15. What we know! • When the processor powers up – it must read its “boot” program from the FLASH memory • The processor does not know what sort of FLASH it will be connected to • When processor powers up, it will “assume” that it is connected to “slowest FLASH” in existence. (common practice) • The first part of the program the processor reads in (boot code) can change the processor to read FLASH more efficiently (faster). Blackfin BF533 I/O

  16. Controlling FLASH operation What we need to worry about Blackfin (like most microcontroller peripherals) has a “GLOBAL” control register and one or more “specific” control registers Blackfin BF533 I/O

  17. InitFlashCPP( ) • Get the FLASH memory to work correctly • May be “many” processes (threads) running on the Blackfin evaluation board (e.g. Audio). • All these processes (threads) may want to use the flash memory for other purposes – meaning InitFlashCPP( ) may have already been called by another thread before your code uses it (or perhaps your code is run more than once) • InitFlashCPP( ) { /* Concept only */ If FLASH memory already configured -- ¿How can we know this? -- Perhaps something that changes during initialization! – return without changing the initialization Else { configure Memory Bank control register THEN configure Global control (turns on the FLASH) } } Blackfin BF533 I/O

  18. Set the Bank control register • Reset value – the way the processor powers up • Will probably work “as is” but not efficient – “slow reads” by default (commonpractice for hardware) Default Slow (15 cycles for each read and write operation) Blackfin BF533 I/O

  19. Memory control access speed (default slow) – Diagram often appears in quiz DEFAULT Processor sends out address and waits 15 cycles before sending a “do a read operation” command to memory. The processor waits another 15 cycles before the actual read occurs. Blackfin BF533 I/O

  20. Set General Control Register • Reset value (Processor power up state)leaves “CLKOUT” disabled – is that important?(Meaning do WE have to turn it on (set bit 0 to 1)?) What parts of the operation of this register must we “know” how to do? Unanswered at this time. We don’t know what bits are critical NOT to change. SO CHANGE USING AND and OR instructions when setting All Banks enabled Blackfin BF533 I/O

  21. InitFlashPortCPP( ) CHANGE INTERFACING FROM ASM TO CPP CODE • Get the Port to work correctly as output for pins PB5  PB0, leaving other pin behaviour (6 and 7) unchanged. (Use AND and OR instructions) • Documentation says the “Flash Direction” register allows you to choose whether the pin works as an “in” pin or works as an “out” pin (common practice) Blackfin BF533 I/O

  22. InitFlashPortCPP( ) • Get the Port to work correctly as output for pins PB5  PB0, leaving other pins unchanged. (Set as “Output” to control the lights) Used during Write and Read operations Write 1 to a bit -- turn on Write 0 to a bit -- turn off Name of “OUR” part WARNING STARTS AT 0 BOTH BITAND LEDNAMES LED 5 Leftmost on Blackfin panel LED 4 LED 3 LED 2 LED1 LED0 Rightmost Blackfin BF533 I/O

  23. Key issues -- InitFlashPortCPP() CHANGE INTERFACING FROM ASM TO CPP CODE • Set direction to 1 (output) on lower 6 pins leaving other direction values unchanged • NEED TO REVIEW ENCM369 – OR assembly code instruction needed – 8 bit values (byte) – READ, USE OR, WRITE • Read EBIU “direction” register into processor core data register (makes a copy) (HOW?) • Set another processor data register to 0x3F (0011 1111). • Need to know basic binary and hexadecimal patterns for common numbers – decimal confusing when used to show “on” and “off” values – no calculators allowed in exams and quizzes • OR the two data registers (HOW?) • Write “modified copy” back into “direction register” (HOW?) • PROBLEM to overcome – how do we do “byte” read and writes to Blackfin memory using “C++”? Blackfin BF533 I/O

  24. WriteFlashLEDCPP( ) CHANGE INTERFACING FROM ASM TO CPP CODE • Write ‘1’ (on) or ‘0’ (off) to the Port to activate LEDs connected to pins PB5  PB0, leaving other pins on that port unchanged in value. (common practice) LED 5 Leftmost LED 4 LED 3 LED 2 LED1 LED0 Blackfin BF533 I/O

  25. Key issues WriteFlashLEDASM( input_value) EXAMPLE NOT YET BEING DONE IN HIGH LEVEL C++ • Write ‘1’ (on) or ‘0’ (off) to the Port to activate LEDs connected to pins PB5  PB0, leaving other pins unchanged. HOW TO DO THIS OPERATION • Read 8-bit BYTE “LED data register” into 32-bit processor data register (makes a copy in R1) • Keep “top” 2 bits (AND operation) of copied value (8 bit) in 32-bit register • Keep “bottom” 6 bits of “in-par” 32-bit in_value (R0) that is passed into the subroutine • OR the two processor data registers (R0, R1) • Write “modified 32-bit copy” back into “LED data register” – 8-bit byte operation needed PROBLEM: “byte (8)” operations using word (32) sized registers Oips Blackfin BF533 I/O

  26. Things we STILL need to learn • How do we put a 32-bit value (long int) into a register (data Rn or pointer Pn)? • How do we put an 8 or 32-bit value into memory? • How do we handle byte operations (8-bit)? • How do we do AND and OR operations on Blackfin? – Do in ASM and CPP? • How similar is Blackfin to MIPS when handling these issues (ENCM369)? Meaning can we use ENCM369 ideas with the Blackfin? Blackfin BF533 I/O

  27. Agenda tackled • Processors need to send out control signals • General purpose input / output GPIO on processor • Not enough GPIO lines • FLASH memory chip has additional I/O ports connected to Ez-Lite KIT LED’s • What do we need to have happen to make the FLASH memory work as we want? • What new Blackfin assembly language instructions do we need to learn? Blackfin BF533 I/O

More Related