Home
        Section 4.1 - Florida Gulf Coast University
         Contents
1.  109 if Get the temperature a5 an inte  e  g DSTACK F 170 tempC x10   la75 temperature 10L switch  i    0 put i7  PORTC    PORTC     toggle LED val case i    I J  a Tam  E DSTAL ahd  3 f   putche 173      Send the temperature data vis void nain roid     anc     474    f Divide by 10 to get the proper           lt   ray Fe  gt       gt   Messages an FT        Errors A wWamngs       A Messages i  Find i Files    291 Insert       Figure 4 13 Screenshot of the CodeVisionAVR IDE with an emphasis on the Errors message  window     4 1 1 14 Keep the CodeVisionAVR IDE open and go to the Uploading an Application  section 4 2 2 to program the target MCU with the application produced in this section     This concludes writing a sample application that can be used to test USART  communication where data is sent from the STK500 to the host PC  The variables PINA and  PORTC shown in the code given in step 4 1 1 11 are the defined in the mega8515 h library  header file  which is automatically included when the code is generated from steps 4 1 1 9 and  4 1 1 10  These variables allow for control over the physical PORTA and PORTC headers  A  variable given by PINx accesses all pins of PORTx where x represents an appropriate port letter    from A through E  Individual pins of a port header can be accessed using the dot operator    Vincent A  Rosa Florida Gulf Coast University Page 11 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    follo
2. Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    4  Application Programming   4 1 Writing an Application   The C programming language  not C    is utilized to develop the applications that are uploaded  to the microcontroller used in this project  However  other languages  such as Assembly and  Pascal  can also be utilized as long as the code can be translated into a HEX or ROM file  The  purposes of these file types are further explained in section 4 2  Uploading an Application  The  following subsections provide programming examples for the ATmega8515L MCU     4 1 1 STKS00 External Communication Protocol  USART    The USART available on the STK500 is dependent on the MCU installed in one of the target  sockets  1   and it is used to communicate from the target MCU to various other devices  10   In  this project  the target microcontroller is the ATmega8515L  which is installed in socket  SCKT3000D3 as shown in Figure 1 6  The USART interface of the STK500 consists of three  registers  the USART control and status register  the USART baud rate register  and the USART  data register  which is either 8 bit or 16 bit depending on the CPU of the target microcontroller    10   The ATmega8515L is an 8 bit AVR    e  it has an 8 bit RISC CPU  so its USART data  register 1s an 8 bit register    The keywords given to the USART registers by the CodeVisionAVR library for  ATmega8sg515L microcontrollers are UCSRA  UCSRB  UCSRC  UBRRH  and UBRRL where t
3. Direction  Pullup OQutput Value  Bit 0 In T Bro BitO In P  Bitd  Bil In T  Bt  Bit1 In P  Bit 1  Bit2 In T  Bit2 Bit2 In P  Bit 2  Bita In T  Bt3 Bit3 In P  Bit 3  Bit4 In T Bit Bir4 In P  Bit 4  Bit5 In T Bit 5 Bir In P  Bit S  bit In Ti Bitb Bit amp  In P  Bit  Bit 7 In T Br  Bit  In P  Bit     Figure 4 6 Screenshots of CodeWizardAVR Ports setup for PORTA  From left  to right  PORTA default setup  PORTA after toggling all Data Direction values     4 1 1 7     Select the    PORTC    tab and change the settings to match those in Figure 4 7   This is done by toggling all values in both the Data Direction and Pullup Output  Value sections  1 e  click on the fields that contain    In    to change them to    Out     and    then click on the fields that contain    0    to change them to    1            Vincent A  Rosa Florida Gulf Coast University Page 5 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    External IRQ Timers USART External IRAQ Timers USART  Analog Comparator SPI 2C 1 Wie Analog Comparator SPI 12C 1 Wire  LCD Bit Banged   Project Information _ LCD Bit Banged     Project Information  Chip External SRAM Ports Chip External SRAM Ports  PorttA PotB PortC PotD Porte Pot PotB PotC PotD  Port   Data Direction   Pullup Output Value Data Direction Pullup Output Value  BitO In T Bio BitO Out 1 Bo  Bit1 In T  Bit Bit  Out 1  Bit  Bit2 _In Ti Bit2 Bit2 Out 1 Bit2  Bit3 In T  Bit3 Bit3 Out 1  Bit 3  Bit4 In T Bit4 Bit 4 Ou
4. USAF  i Generate  Save and Exit  Interrupt  m YA Exit    Transmitter    Ts Interrupt    Figure 4 9 Screenshot of generating and  saving a program formed using the  CodeWizardAVR within CodeVisionAVR     4 1 1 10 Goto your desired directory  say    C  Documents and Settings Administrator My  Documents     and create a new folder  say    STK500_TestProg     Note  it is good  practice in CodeVisionAVR development to save all project files for a project within  the same designated folder   Go into this folder and give the C file a name  say     stk500_test_prog    as shown by the first pop up window within Figure 4 10  A  series of pop up windows will appear for naming other files  Simply provide a name  for these files     they can be named with the same name as the C file  but they must be    given different extensions as shown in Figure 4 10     Vincent A  Rosa Florida Gulf Coast University Page 7 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor            Save C Compiler Source File 203 Save C Compiler Project File Leg  Save inc      STKS00_TexProg      O F eE   Savei O STES00_TestProg v    tT E E    4   4  PE         biy Recent   My Recent  Documents   Documents  ri   F 4  Desktop Desktop  AF  a     My Document  hy Documents                                           al lg  43 y  My Computer My Computer  a  File nama  k500_lest_prog c il   Save     J File name atk S00 test prog sat     Save      rot a EE ars D i    My Met
5. e     SDA Bit    is set to    O    and the    SCL Bit    is set to    1     This parallels the hardware    setup established in the Hardware Connectivity section 2 3 2     Vincent A  Rosa Florida Gulf Coast University Page 12 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    External IAG Timers USART  LCD Bit B anged Project Information  Chip External SRAM Ports  Analog Comparator SP 2 1 Wire  l2 Port    PORTE    SDA Bit   0  a  SCLBt 1       LM75   D51621    PCFS563  Fi 4    v  Enabled Addess  M 0    _  Output Active High    Temperature    L    Hyst   75  40 5    80 34    Figure 4 14 Screenshot of the CodeWizardZVR  I2C setup  The I2C Port is set to PORTE and  LM75 is set as Enabled     4 1 3 3 Perform steps 4 1 1 9 through 4 1 1 13 with the following revisions    e 4 1 1 9     Perform as given    e 4 1 1 10     The same directory can be used     C  Documents and  Settings Administrator My Documents      but create a different folder  say     STKS00_DAQ_ Temp     Also  use a different name to save the files given by the  series of pop up windows  say    stk500_daq_temp          e 4 1 1 11     Add the following code from Appendix section A 2 2 1 instead of the code  originally given at this step  the areas the following code 1s added are relatively  located at the beginning and end of the program given in section A 2 2 1 of the  appendix         Standard Input Output functions  finclude  lt stdio h gt   7 Contains    pr
6. he  UCSRx keywords correspond to the high  A   middle  B   and low  C  sections of the USART  Control and Status Register and the UBRRx keywords correspond to the high  H  and low  L   sections of the USART Baud Rate Register    The USART data register is controlled by the specialized I O functions provided in the  avr libc library  Such input functions include getc and gets and such output functions include  putc  puts  and printf  These are the same functions available in the cstdio header of the  C Library  libc   11   but they have been revised in the AVR C Library  avr libc  for USART  communication with respect to AVR microcontrollers  10     The required hardware setup to enable the use of the USART on the STK500 is given by  the instructions in section 2 2  Appendix section A 2 1 provides a sample program that can be  used to test USART communication between the board and its host  Sections 3 1 and 3 2 of this    Vincent A  Rosa Florida Gulf Coast University Page 1 of 14  Spring 2009    Atmel AVR STK500    Communicating with a User Manual    Host PC and Temperature Sensor    document explain the necessary steps to take before applications development can begin on the    host PC  The following instructions describe steps to implement the application in Appendix    A 2 1 using the CodeVisionAVR IDE     4 1 1 1    Open the CodeVisionAVR IDE on the host by going to    Start        All Programs           CodeVisionA VR     and selecting    CodeVisionAVR C Compiler Evaluati
7. ia Player   33  Windows Messenger   A   windows Movie Maker     gt  Windows Search    Sie nacre      Figure 4 1 Screenshot of how to start CodeVisionAVR Evaluation     Florida Gulf Coast University  Spring 2009    Page 2 of 14    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    4 1 1 2 Go to the    File    menu and select    New    within the CodeVisionA VR window    shown in Figure 4 2        ike CodeVisionAVR  File Edit Search View Project Tools Settings Help       D New Ctrl M     Open Ctrl 0   ka Reopen b  be Code Information  4       EJ Page Setup       Exit    Figure 4 2 Screenshot of how to create a  new source file or project in  Code VisionA VR     4 1 1 3 Select    Project    and click    OK    in the Create New File pop up window shown in  Figure 4 3     B Create New File x     File Type       Figure 4 3 Screenshot of the  CodeVisionAVR pop up selection  window to decide whether to  create a new source file or project     Vincent A  Rosa Florida Gulf Coast University Page 3 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    4 1 1 4 Select    Yes    in the    Confirm    pop up window shown in Figure 4 4 to use a    wizard that will automatically generate certain AVR code based on the settings given        Confirm         You are about to create 4 new project     Pd Do you want to use the CodeWizardavR     Figure 4 4 Screenshot of the pop up  window confirming whether or not t
8. intt      and sorintt        include  lt delay h gt     Contains  delay_ms      include  lt stdlibuwh gt     Contains  abs            x  x The  int 1lm7 75_temperature_10 unsigned char chip   function      returns the temperature in degrees C times 10 retrieved from    Vincent A  Rosa Florida Gulf Coast University Page 13 of 14  Spring 2009    Atmel AVR STK500    Communicating with a User Manual  Host PC and Temperature Sensor      the LM75 sensor with the address  chip        CAUTION  A 300ms delay must be present between two successive    calls  to this LUNE Lom     ry       Get the temperature as an integer in degrees Celcius times 10  tempC_x10   lm7 5_temperature_10  0      PORTC    PORTC     toggle LED values       Send the temperature data via USART      Divide by 10 to get the proper whole number temperature      Append the the decimal value of the temperature to one place by  iJ Using modulus   10   princi   aisa Un tenpe   10710 cabs  tenpe x1  0410  F     PORTC    PORTC        Delay for DELAY_ms amount of time    delay_ms  DELAY_ms      e 4 1 1 12     Perform as given     e 4 1 1 13     Perform as given  in this case  however  all of the files compiled and built    are from the C file given by    stk500_daq_temp c            e 4 1 1 14    Perform as given     This concludes creating the software that correlates with the DAQ system formed    between the STK500 PCB and myTWI Temperature Sensor  The CodeVisionAVR User Manual     13  has more information on the functio
9. lf Coast University Page 10 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    Be CodeVisionAVR       host Shared Folders truth324 On My Mac Documents  COLLEGE  FGCU  Spring 2009 Courses CEN 4935   Senior Software Eng      ogg  Fie Edit Search View Project Tools Settings Help    Bes  Hegooc   ABS    B A E P Bee eG id                                  annene naglo EN  Ssa  AGB  2 NO          a T r 1 Sl it a i ea       i RTTA ie E E Pana ore Arnie i m x i Ea A EFR i  lt a    i  Code Navigator PEI b Code Information O  F 0   Whoe Shared Folders uth324 On My Mac Documents COLLEG EJ    Code Templates   Fa Clipboard History 4             amp M Codevisond VA   H ak500_ daq temp c Hotes SkS00_daq_temp c if t       a Project stk oul dag t   E Includes 153 if bosz fo ali  ai Noles  4  Macias 154 ff O  S  polarity      stk500_ dag temp    FU Functions 155 im 7S init  0 75 80 0    if i  d    Headers 156    delay h 157   while  1   a  Ej i2c h 158 A i do     in 5i hi 159      Place your code here    E 4 se z   ry   meas Sh 160 A fe pile      stdang h 161   The  int la75 temperature iit while  i j     stdin kh 162   returns the temperature in de  shdlib  h      163   the LAMIS sensor with the addre  ki Other Files l Function Call Tree  0 22  J 164    Gna      fT  man al  165   CAUTION  A J00asr delay must be be     DSTACK Fur  0  Lio ri ca iis   o this fume tion        0 pinti 167    f switch       E DSTACK Furo     468 Cami     0  pii
10. ns available in the CodeVisionAVR LM75 library given    by the 1m75 h header file  which is automatically included when the code is generated from    instruction 4 1 3 3     Vincent A  Rosa    Florida Gulf Coast University Page 14 of 14  Spring 2009    
11. o use  CodeWizardA VR to generate a new project     4 1 1 5 Under the tab    Chip    within the CodeWizardA VR window  select the target  microcontroller  in this case  the ATmega8515L  from the    Chip    drop down menu  and change the    Clock    setting to the appropriate System Oscillator Clock frequency   fosc  with respect to the target microcontroller  in this case  3 6864 MHz  as shown    in Figure 4 5     External IRG Timers USART  Analog Comparator SFI lC 1 Wire  LCD Bi Banged   Project Information   Chip External SRAM Ports    Chip  AT mega8515L v    Clock  3 6864 4  MHz        Check Reset Source  Program Type     Apolication w    Figure 4 5 Screenshot of CodeWizardAVR Chip setup     Vincent A  Rosa Florida Gulf Coast University Page 4 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor    4 1 1 6     Select the tab    Port    and change the settings under the    PORTA    tab to match  those in Figure 4 6  This is done by toggling all values in the Pullup Output Value    section  1 e  click on the fields that contain    T    to change them to    P         External IRQ Timers USART External IRO Timers USART  Analog Comparator   SFI lC 1 Wire Analog Comparator SFI Lal  1 Wire  LCD Bit Banged   Project Information LCD BitBanged     Project Information  Chip External SRAM Ports Chip External SRAM Parts  Pot   PotB   PortC   Port D   Port E PotA   PotB   Pot C   PotD   Port E   Data Direction  Pullup Output Value Data 
12. on    as    shown in Figure 4 1     Vincent A  Rosa    My Computer    pe ADT 4    Microsoft  Visual Stu       es CEETIY  S Ah e     My Network MI ELYIS  Places Traditional    E 2    Recycle Bin Remote  Desktop      ei   tJ  Shortcut to   el aipcya icy sy     Internet  Explorer    pi  td    Chavbeiik ba    Hal Administr    Internet  Internet Explorer    E mail  Yahoo  Mail    Dd Microsoft Update      Microsoft Visual Stud    fo Notepad   es HyperTerminal   cV CodevisionavR Eval    2 04 0a       w Microsoft Office Wor    P  Shortcut to      STKS00_DAQ_HostP         Microsoft Update  Set Program Access and Defaults    Windows Catalog     an  Accessories   fan  Administrative Tools    T  Atmel AVR Tools   fm CodeVisionAVR   an Games    T  MATLAB 7 1   fan  Microsoft Developer Network   an  Microsoft Office    M  Microsoft SQL Server 2005    Codevision  YR C Compiler Evaluation    EY CodeVisionAVR C Compiler Evaluation Help  5  Uninstall CodeVisionAYR C Compiler Evaluation        Microsoft Visual Studio 2008   M  Microsoft Windows SDK   6 04      National Instruments    M  PL 2303 USB Serial Driver   M  Powerlso   Van Startup   an Symantec Client Security   M  winavR 20090313    m  windows PowerShell 1 0    winrar   M winsce       Acrobat Distiller 9   A   amp crobat com   A Adobe Acrobat 9 Pro   lc Adobe LiveCycle Designer ES 8 2  ES Adobe Reader 9     Internet Explorer   Ww MSN     4 National Instruments LabVIEW 8 6   A  Outlook Express       Remote Assistance        Windows Med
13. s            Codevisiona VA   Y   Clean Up   Gil Save Al shift ctri s   m Project  stk 500   r ec  Motes  F Close ea  aia stk500_tesl           Close All  Al Other Files     li Convert bo Library    Page Setup    Print Preview i Motes  EB Print Ctrl P       Configure        Exit m I    M LIL l oie    Figure 4 11 Screenshots within the CodeVisonAVR IDE  From left  to right  how to save all project files  how to build all project files       Information  Compiler   Assembler    Chip  AT mega  5i5L   Clock frequency  3 666400 WHz  Program type  Application  Memon modet Small   Optrnize for  Sre       printf features  int  width   e ecant features  int  width  Promote    char    te    int     Yes      char    is unsigned  Yes   global    const    stored in FLASH  No  8 bi enum     Yes   Enhanced core instructions  Yes  Automatic register allocator     ies  Smart register allocation  Yes    9210 line s  compiled   No errors  a  Ho wamings   Bit variables size  0 byte s    Data Stack area  60h to DFh    Data Stack size  128 bytes   Estimated Data Stack usage  34 byte s     RAM Global variables area  EOh to ESh  RAM Global variables size  6 byte s     Hardware Stack area  EGA bo 25F Rh  Hardware Stack sre  378 byte s     Heap size  0 bytes     EEPROM usage  0 byte s   O08 of EEPROM  Program size  934 words  1868 bytes   22 8c of FLASH       Figure 4 12 Screenshot of the CodeVisionAVR    Information    pop   up window that appears after building project     Vincent A  Rosa Florida Gu
14. t 1  Bit 4  Bit 5 _In T Bits Bit5 Out  1  Bits  Bit6 _In U Bit Bit6 Out  1  BitG  Bit  In T  Bit  Bit  Out  1  Bit     Figure 4 7 Screenshot of CodeWizardAVR Ports setup for PORTC   From left to right  PORTC default setup  PORTC after toggling all values     4 1 1 8 Select the    USART    tab  check both    Receiver    and    Transmitter     and change  the    Baud Rate    to 115200  The settings should match those given by Figure 4 8     Analog Comparator SP I2C 1 Wire Analog Comparator   SPI l2C 1 Wie  LCU Bit B anged Project Information LCU Bit B anged Project Information  Chip External SRAM Ports Chip External SRAM Ports  External IRG Timers USART External IRG Timers USART      Receiver Receiver     As Interrupt     Transmitter Transmitter       Tx Interrupt  Baud Rate  195200 w  1  x2    Baud Rate Eror   0 22    Communication Parameters     8 Data  1 5top  No Parity  4     Mode  Asynchronous wt       Figure 4 8 Screenshot of CodeWizardAVR USART setup  From  left to right  USART default setup  USART after enabling Receiver  and Transmitter and setting the Baud Rate     Vincent A  Rosa Florida Gulf Coast University Page 6 of 14  Spring 2009    Atmel AVR STK500 Communicating with a  Host PC and Temperature Sensor    User Manual    4 1 1 9 Goto the    File    menu and select    Generate  Save and Exit    as seen in Figure 4 9     4h CodeWizardAVR   untitled cwp  File Edit Help    Ty New         Open       H Save ac T  IE Save As      ct Informa  7 Fort   ia  Program Preview 
15. visible  delay_ms  1000      printer   Goodbyel r n     POR EC     PORTC        4 1 1 12 Got to the    File    menu and select    Save All    as seen in Figure 4 11 to save all    changes made to any of the project files     4 1 1 13 Go to the    Project    menu and select    Build All    as shown in Figure 4 11  Doing    this will build and compile all necessary files  including the HEX file used to    program the flash memory of the target MCU  from the code provided within the    target C file  in this case  from    stk500_test_prog c            Itis possible for compilation    errors to occur during this process  but the results within the    Information    pop up    window should look similar to those in Figure 4 12 if none appear  If any errors    exist  they will appear in the    Errors    message window shown in Figure 4 13  The    IDE will provide suggestions within this window on how to fix any incurred    compilation errors  Click    OK    within the Information pop up window to proceed     Vincent A  Rosa    Florida Gulf Coast University Page 9 of 14  Spring 2009    Atmel AVR STK500 Communicating with a User Manual  Host PC and Temperature Sensor       SE CodeVisionAVR       hostis SE CodeVisionAVR   C  Documents and Settings Administra  File Edit Search view Project Eile Edit Search View Project Tools Settings Help  Ty New Ctr4 N f Be    H H77 compie a k  Open CO   Pe Build Shift F9 f    m p    E Reopen z   KP Rt SS Build All CtrF9  fe Code Navigator l  TH Save d
16. vwotk Save at type C Compier files  7c  ha Cancel   bu Network Save as lype Project files   pri w    Cancel      Save C  cvavreval bin untitled cwp As AX  1   E    i    Savein E STKS00 TestPiog w vy cE  fie              4    My Recent  Documents  iia  Desktop  oy     Hy Documents    Pi     tly Computer    eJ File name atk 500_tast_prog t     Sav      Y       hy Netwwcrk Save as lype Codetwizard   VR project files  cwpl w     Cancel                        l    Figure 4 10 From left to right  top to bottom  pop up window to save the C source file   c extension      pop up window to save the C project file   prj extension   pop up window to save the Code VisionAVR  project file   cwp extension      4 1 1 11 Add the following code to the same areas shown in the program given in    Appendix section A 2 1  these areas are relatively located towards the beginning and    end of the provided code       include  lt delay h gt     Contains    delay_ms            Send the following message via USART communication    printf  USART Communication Test  Succeeded     r n          Check state of PORTA Pins  if  PINA    OxFF     Vincent A  Rosa Florida Gulf Coast University Page 8 of 14  Spring 2009    Atmel AVR STK500    Communicating with a User Manual  Host PC and Temperature Sensor          Tf a button is pressed  input pulled low   toggle bits on PORTC    POR LC     PORTC        Send the following message via USART communication    priantt  Hello  r n          Delay so flashing LED s are 
17. wed by the appropriate pin number  For example  PINB 0 accesses pin 0 of PORTB  Le     PBO on the board  and PIND 7 accesses PD7     4 1 2 myT WI Communication Protocol  IC   The myTWI Temperature Sensor uses the TWI  I   C bus  to communicate with external devices  where I   C is a serial data bus developed by Philips Semiconductors in the 1980s and is now a  worldwide standard  5   The IC bus is intended for communication of relatively small amounts  of data across relatively short distances  5     The serial data  SDA  and serial clock  SCL  lines shown in the pinout in Figure 4 14 are  the physical elements responsible for IC data communication  The software used to parallel  these hardware constructs is given in Appendix section A 2 2 1 and is further explained in    section 4 1 3     4 1 3 DAQ with the STK500 and myTWI   The instructions provided within this section establish a data acquisition system with an STK500  evaluation board  a my WI Temperature Sensor  and a host PC  Performing the following steps  will reproduce the program given in Appendix section A 2 2 1  The specifics of the code are    explained by the comments given within the application     4 1 3 1 Perform steps 4 1 1 1 through 4 1 1 8   4 1 3 2 Select the    I2C    tab  select    PORTE    from the    I2C Port    drop down menu  and  then check    Enabled    under the    LM75    tab  The settings should now match those  shown in Figure 4 14  if they do not match  change them so they do   Notice how th
    
Download Pdf Manuals
 
 
    
Related Search
    
Related Contents
Clipsal C-Bus C-5000CT2 Spectrum colour LCD Touch Screen  Kowa H Operating Instructions  TEW-432BRP Guia de Instalação Rápida  Manuel d`utilisation  Bedienungsanleitung snom 300, 320, 360, 370  Operating Instructions - 4 Office Technical Support  Philips MCM280D Micro Hi-Fi System  ESPECIFICACIÓN DE PRODUCTO VEGENAT  "user manual"      Copyright © All rights reserved. 
   Failed to retrieve file