Home
Support - the Patrice Kadionik`s HomePage
Contents
1. start Character Es Byte Count of data bytes EE PE Address Of first data ee RRR Record Type 00 data Ol end of record Data Bytes t Checksum GE t I CAAA AT TT Ae acu db oH ox C An examples 10000000DB00E60F5F1600211100197ED300C3004C 1000100000000101030507070F0FIELIESESPT7ETEFEFZ 01002000FFE0 0DODOOOTEE This information comes from Microprocessors and Programmed Logic Second Edition Kenneth L Short 1987 Prentice Hall ISBN 9 135 590606 2 Provisions have been made for data spaces larger than 64 kBytes The above reference does not discuss them I suspect there is a start of segment type record but I do not know how it is implemented pk enseirb 2004 v2 0 70 1 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 14 BIBLIOGRAPHIE A Hardware et software MOTOROLA Page www www enseirb fr kadionik 68hc 1 1 html Manuel lt M6SHC11 REFERENCE MANUAL gt M68HCIIRM AD Guide M68HCIIA8 PROGRAMMING REFERENCE GUIDE MC68HC11A8RG AD lt Les microcontr leurs HC11 et leur programmation gt de C Cazaubon Edition Masson Enseignement de 1 Electronique ISBN 2 225 85527 7 Manuel lt Technical Summary 8 bit Microcontrollers MC68HC11A8 Al AO gt Note d a
2. CMPA BFE HH2F 2618 BHE 0021 0031 3 DBE BSR HAASE 6433 8D31 BSR HB6 6 0035 17 TEA GIEL BD1F BSR HOS Figure 16 TALKER de PCBUG11 visualis depuis l mulateur L utilisation de l mulateur 68HC11 ne sera pas abord e durant le TP pk enseirb 2004 v2 0 27 J I t LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 8 DERNIERES MINUTES faut noter que le microcontr leur 68HC11 version Al n est plus fabriqu par Motorola a t remplac par le 68HC11 version El compatible broche broche Des diff rences existent n anmoins au niveau des fonctionnalit s internes r sum es ci apr s 512 octets de RAM au lieu de 256 Une ROM interne contenant le moniteur BUFFALO est int gr e et visible de SD000 SFFFF quand son utilisation a t valid e Cela permettrait sur la carte m re de remplacer le moniteur en ROM externe par le code d une autre application ce que l on ne fera pas ici On utilisera donc le moniteur BUFFALO en ROM externe Protection des critures en EEPROM par validation de bits du registre BPROT La broche 3 du port A est maintenant bidirectionnelle Dans le processus de bootstrap le JMP 0 est fait apr s 512 octets charg s en RAM interne ou apr s avoir re u 4 caract res IDLE ligne l tat 1 durant la dur e de r ception de 4 caract res TRES IMPORTANT Il est possible que le moniteur BUFFALO en ROM interne soit valid par une fausse manipulatio
3. 1 lt special test gt et le bit IRV reste a0 BF 103C ES validation des acc s externes depuis le mode bootstrap sous PCBUG11 A partir de ce moment il est possible d acc der aux ressources externes du 68HC11 et donc de t l charger des programmes en RAM externes depuis PCBUGII PCBUGII permettra le t l chargement des fichiers SRecord en m moire de mani re simple En revanche PCBUGI 1 a quelques inconv nients tels que l occupation d une grande partie de la RAM interne ainsi que l obligation de d marrer le 65HC11 en mode bootstrap pk enseirb 2004 v2 0 15 a D 5 1 23 LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik De plus l utilisation de la liaison s rie par le programme utilisateur rompt la liaison entre le TALKER et PCBUGI1 On ne peut dans ce cas faire des op rations d E S sur la liaison s rie avec PCBUGI1 Dans ce dernier cas il vaut mieux utiliser le moniteur BUFFALO 4 OUTIL JBUG11 L outil JBugll est une version am lior e de PCBUGII fonctionnant sous Windows Il poss de donc une interface graphique conviviale et permet de faire les m mes choses que PCBUGII L interaction avec JBug11 se fait par les menus ou partir de la fen tre de commandes que l on peut taper Il est noter que JBug11 est compatible au niveau des commandes en ligne BF MD Break Points JBugl11 Tie Edt Settings Calculator Help EE tiel xl A
4. 1 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik M ENSEIRB QUEE LECTRONIQUE INFORMATIQUE amp RADICCOMMUNICATIONS BORDEALS ETUDE ET MISE EN UVRE DU MICROCONTROLEUR 68 11 Patrice KADIONIK kadionik enseirb fr www enseirb fr kadionik pk enseirb 2004 v2 0 1 ICT ees LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik M o TABLE DES MATIERES Een 3 I Pr sentation de la carte m re ENSEIRB 68HCII 5 1 1 Caract ristiques du microcontr leur 68HC11 5 1 2 Sch ma lectrique de la carte 6 159 Decodase dq 8 1 4 Cartographie m moire de la carte me re 8 2 Pr sentation de la carte d entr es sorties 10 0 72 3 1 Fonctionnement du 68HC11 en mode bootstrap avec PCBUG11 12 3 2 T l chargement d un programme objet avec PCBUG11 14 Ou bi GI l ua us Uis eM EUN M EE 16 5 R alisation de programmes assembleur et C 17 5 1 Programma
5. interpreted as a hexadecimal value display the count of remaining character pairs in the record address A char 4 6 or 8 field These characters grouped and interpreted as a hexadecimal value display the address at which the data field is to be loaded into memory The length of the field depends on the number of bytes necessary to hold the address 2 byte address uses 4 characters a 3 byte address uses 6 characters and a 4 byte address uses 8 characters data A char 0 64 field These characters when paired and interpreted as hexadecimal values represent the memory loadable data or descriptive IO Ttormsgtron checksum A char 2 field These characters when paired and interpreted as a hexadecimal value display the least significant byte of the ones complement of the sum of the byte values represented by the pairs of characters making up the count the address and the data fields Each record is terminated with a line feed If any additional or different record terminator s or delay characters are needed during transmission to the target System it is the responsibility of the transmitting program to provide them SQ Record type of record is 50 0x5330 The address field is unused and will be filled with zeros 0x0000 Ihe header information within the data field is divided into the following subfields pk enseirb 2004 v2 0 66 J I t EL G KATA FORAGE a ed DA Se 55 M So
6. taper MM 1035 00 o 1035 est l adresse du registre BPROT Si l EEPROM n est pas pr sente dans la cartographie m moire c est que le registre CONFIG est mal configur attention ce registre se programme comme une case de m moire EEPROM voir le manuel M68HCII REFERENCE MANUAL page 3 5 paragraphe 3 2 2 Le bit concern est d nomm EEON et permet d activer ou non EEPROM LOADS filename filename est le nom du fichier sans l extension SRecord de Motorola S 19 qui se trouve dans le m me r pertoire que PCBUGII utiliser sinon la commande DOS CD c pour changer de r pertoire Les fichiers 519 seront cr s avec le programme assembleur ASMHC11 EXE ou bien par un compilateur crois C C Cosmic ASM point d entr e v rifie que le programme est bien implant en m moire en d assemblant assemblant en ligne point d entr e B600 si le programme est en EEPROM G point d entr e ex cution du programme ligne point d entr e B600 si le programme est en EEPROM S le programme est stopp le 68HC11 revient au TALKER La note d application AS 67 de Motorola indique comment on peut acc der aux ressources externes tout en utilisant PCBUGI1 En effet PCBUGII ne marche qu en mode lt bootstrap gt En revanche il est possible de basculer en mode lt special test gt sous PCBUGII en crivant ES l adresse 103C adresse du registre HPRIO On positionne ainsi les bits SMOD et MODA
7. CONTROL EPROG address Change the EPROM register address CONTROL ERRMSG option Enable or disable display of error messages CONTROL HARDWARE Access COM port directly through hardware CONTROL LAST Toggle the last error msg window on off CONTROL LOG CLOSE Close the open command log file CONTROL LOG OFF Suspend logging to command log file CONTROL LOG ON Enable logging to the command log file CONTROL LOG OPEN Open the command log file CONTROL PPROG address Change the EEPROM register address CONTROL PROTECT Use the RTS to provide memory protection CONTROL RTS Control the RTS line directly CONTROL RIS ON OFF Set RTS line high or low CONTROL TIMEOUT value Display or set the value of serial COM timeout during input IDASM addrl addr2 Disassemble from addrl to addr2 DIR Display disk directory DOS Shell to DOS or execute DOS command mask DB startaddr endaddr Display MCU Memory DEBUG Reserved word IDEFINE symbol value address Define a symbol DEEM macrnam TRACE AUTOSTART Define a command trace or autostart macro DELM macrnam TRACE AUTOSTART Delete a command trace or autostart macro command EDITM macrnam Edit a macro startaddr EEPROM DELAY option endaddr option Display set EEPROM addr range s Set EEPROM erase or write programming time clear EEPROM ERASE Display or chg EEPROM erase before write
8. Command History JBugl1 Addresse ctart Em amp Go Addr MCU Register LC IXXXZXE Ay zx B zx e Gauss CCR 2 Local commands only Info ICTS 0 ID5R 0 E Figure 7 Logiciel JBug11 pk enseirb 2004 v2 0 16 5 1 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik Bi 5 REALISATION DE PROGRAMMES ASSEMBLEUR Programmation en assembleur 68HC1 1 Le jeu d instructions est pr sent dans le manuel lt M68HC11 REFERENCE MANUAL APPENDIX A Il ressemble beaucoup celui du microprocesseur 68000 On se r f rera au document donn en annexe 4 pour une description plus compl te de la programmation en assembleur 68HC11 ainsi que l annexe 2 La production d un objet partir d un programme assembleur 68HC11 est la suivante Edition du fichier source extension du fichier ASC obligatoirement Une directive d assemblage ORG doit tre imp rativement utilis e Assemblage l aide de la commande ASMHC11 EXE ex c i ASMHCII TOTO ASC Le fichier SRecord a t cr pour l exemple 519 ainsi qu un fichier listing pour localiser les erreurs ventuelles pour l exemple TOTO LST T l chargement dans la carte mere Un exemple de fichier crit en assembleur 68HC11 est donn ci apr s On notera les fortes analogies avec l assembleur 68000 PORTA KOU 51000 port data PORTE EQU 100A port E
9. S9 EXAMPLE Record Record Record Record Record Record Record LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik J Hi Ce gt mname is char 20 and is the module name ver is char 2 and is the version number rev is char 2 and is the revision number description is char 0 36 and is a text comment Each of the subfields is composed of ASCII bytes whose associated characters when paired represent one byte hexadecimal values in the case of the version and revision numbers or represent the hexadecimal values of the ASCII characters comprising the module name and description The type of record field is Sl 0x5331 The address field is interpreted as a 2 byte address The data field is composed of memory loadable data The type of record field is 52 0x5332 The address field is interpreted as a 3 byte address The data field is composed of memory loadable data The type of record field is 53 0x5333 The address field is interpreted as a 4 byte address The data field is composed of memory loadable The type of record field is S5 0x5335 The address field is interpreted as a 2 byte value and contains the count of S1 S2 and S3 records previously transmitted There is no data field The type of record field is 57 0x5337 The address field contains the starting execution address and is interpreted as 4 byte address There is no data field The type of
10. T l charger le fichier SRecord ping3 s19 10 V rifier par dump la table des vecteurs et notamment les adresses FFFE FFFF qui contiennent le point d entr e du programme PINGS 11 Reconfigurer la carte en mode tendu et faire un reset Le programme PING3 doit alors s ex cuter On utilisera pour le v rifier le programme Windows HYPERTERMINAL pk enseirb 2004 v2 0 35 A Fos D RE PAR LE NOCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik aL a Bi Lo gt d PARTIE III ANNEXES pk enseirb 2004 v2 0 36 1 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 ANNEXE 1 Commandes de PCBUG11 pk enseirb 2004 v2 0 37 Patrice Kadionik A iP eae LE MICROCONTROLEUR 8 BITS 68HC11 E Li 8 Patrice Kadionik recall The following table lists the Use the host computer keyboard to edit the 11 command line buffer holds the last 16 commands entered edit keys left arrow Moves cursor back one character right arrow Moves cursor forward one character Home Moves cursor to first character End Moves cursor to last character delete left Deletes to the left of the cursor Del Deletes at the cursor position End Deletes from cursor position to the end of line 10s Inserts at cursor position cursor changes to blocked Cursor up arrow Recalls previous commands in reverse order down arrow Recalls last command in rec
11. UTILISATION DU MONITEUR BUFFALO 6 1 Qu est ce qu un moniteur Nous avons vu que le logiciel PCBUGII t l charge un petit programme de 192 octets environ en m moire RAM Un moniteur est un programme beaucoup plus gros 8 Ko environ que l on programme dans une EPROM externe et qui permet donc de remplacer le TALKER de PCBUGI1 Les avantages sont multiples puisque le moniteur occupe tr s peu de RAM uniquement pour quelques variables Il permet de d bugger gt le programme utilisateur grace des commandes int gr es que nous verrons plus loin et le moniteur dialogue avec l utilisateur par l interm diaire d un simple terminal ou l mulateur HYPERTERMINAL Windows L ex cution du moniteur se fait lors du RESET en mode ETENDU et rend libre l utilisation du port s rie apr s le lancement du programme utilisateur 5 2 Cartographie m moire avec le moniteur BUFFALO Voici le mapping m moire de la carte m re avec le moniteur BUFFALO version 3 4 int gr RESET VECTORS etc INTERNAL EEPROM Fi acre EPROM BUFFALO MONITOR 8 EXTERNAL USER DR RA CHE V o REGS ZERO PAGE MEMORY INTERMAL RAM Figure 13 Cartographie m moire en mode tendu avec le moniteur BUFFALO 3 4 Elle est identique celle que nous avons d j vue une zone de 8 Ko tant r serv e au code du moniteur pk enseirb 2004 v2 0 24 MA NGABA LE MICROCONTROLE
12. baudrate 9600 Figure 10 Squelette du fichier ping c Les tapes de compilation ditions de liens et g n ration du fichier SRecord sont r alis es par le lancement d un fichier DOS batch BAT ping bat echo off CGO v e DING if errorlevel 1 goto bad clink Scho echo Linking clnk o m pang LIRE 1f errorlevel 1 goto bad chexa Scho echo Converting o 619 DING Al 1 errorlevel 1 goto bad cob cho pk enseirb 2004 v2 0 22 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Hi Ce echo Section size Cob n DING ALI 1f errorlevel 1 goto bad echo echo echo OK goto sortie bad echo echo echo BAD Sortie Figure 11 Fichier ping bat Au vu de ce qui est crit dessus le fichier de commandes pour l dition de liens s appelle ping kf 1 link command file for test program Copyright c 1995 by COSMIC Software seg text b 0x2000 n text program start address toeg CONSE LEXL constants follow program seg data b 0x3000 data start address bss ping o application program lSDbhcll o 68 11 enseirb lib de7loglciel 69hdgll ox22711b5713bi hll C library ds Logilczsel 6958hcoll 0x3271315713bm hli machine LiDrary Figure 12 Fichier ping lkf pk enseirb 2004 v2 0 23 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi K 6
13. est pas utilis e ici Le PORT A n cessite une attention plus particuli re notamment au niveau du registre de contr le PACTL qui configure le TIMER partag avec le PORT A Nous choisissons alors d utiliser toutes les broches possibles en sortie La carte d E S est fig e de la mani re suivante PORTE entr es PEO PE7 PORT A entr es PAO 1 2 sorties PA4 PAS PA6 PAT Le sch ma lectrique est donn ci dessous on retrouve les 2 connecteurs du PORT A et PORT E Le PORT E est interfac avec un boitier DIL de 8 micro switchs dont les sorties sont reli es des r sistances de pull down de 10 KOhms Le PORT A est partag en 2 Les 3 bits de poids faible sont reli s de la m me mani re que le PORT E gr ce aun boitier micro switch de 4 interrupteurs les 5 bits de poids fort sont reli s un circuit buffer 74HC245 qui alimente 5 LEDs de visualisation Il faut en outre noter que la sortie PA3 est utilis e par le moniteur BUFFALO et par le noyau temps r el u C OS et est ainsi dans ces 2 cas indisponible pk enseirb 2004 v2 0 10 Ng LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik TM _ vic PF EP FT 1 Figure 5 Sch ma lectrique de la carte d E S pk enseirb 2004 v2 0 11 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 3 UTILISATION DE PCBUG11 Sch Fonctionnement du 68HC11 en mode bootstrap avec P
14. 2004 v2 0 53 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw RB Bi LS E Sign Characteristic Mantissa Float representation Sign Characteristic Mantissa Double representation USING THE COMPILER This chapter explains how to use the C cross compiler to compile programs on your host system It explains how to invoke the compiler and describes its options It also describes the functions which constitute the C library This chapter includes the following sections Invoking the Compiler File Naming Conventions Generating Listings C Library Support Invoking the Compiler To invoke the cross compiler type the command cx6811 followed by the compiler options and the name s of the file s you want to compile All the valid compiler options are described in this chapter Commands to compile source files have the form Gx6611 options stfriles le s cx6811 is the name of the compiler The option list is optional You must include the name of at least one input file lt file gt lt file gt can be a C source file with the suffix c or an assembly language source file with the suffix e You may specify multiple input files with any combination of these suffixes any order If you do not specify any command line options cx681 1 will compile your files with the default options It will also write the name of each file as it is processed It writes any error messages to STDERR The follow
15. ENV Define Environment save options EPROM startaddr endaddr Display clear set EPROM address range s EPROM DELAY option FIND byte word addrl addr2 FIND mnemonic addrl addr2 Set EPROM erase or write programming time Find all occurrences of byte or word between addrl amp addr2 Find all occurrences of mnemonic between addrl amp addr2 IG addr Start user code execution HELP command Display help information HELP MCU topic Display help on specific MCU topic KLE Kill last error message LOADM filename macroname Load macro des from default or user file LOADS filename Load S record file into MCU memory ILS symbol LSTM mname TRACE AUTOSTART Display symbols loadaddr Display macro names or definitions pk enseirb 2004 v2 0 39 QUEE IMD startaddr addr MOVE addrl addr2 addr3 endaddr FLEE PRD LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Hi L 8 Display MCU memory Modify memory from addr Move MCU memory between addrl amp addr2 to addr3 IMS addr byte word byte word Set MCU memory byte s or word s IMSG string Display message in main window NOBR address Remove all or specified breakpoints PAUSE ms Wait for any key press or delay time PRINT Display PCbugll version number PROTECT startaddr endaddr Display clear or set write protected address range s QUIT Y
16. LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi bh 8 and data sections will be located at absolute memory addresses The linker is used with a command file acia Ink in this example An application that uses one or more object module s may require several sections code data interrupt vectors etc located at different addresses Each object module contains several sections The compiler creates the following sections text code or program section e g ROM const constant section e g ROM data all static initialized data e g RAM bss all non initialized extern data e g RAM bsct all data in the first 256 bytes see dir in chapter also called zero page In our example and in the test file provided with the compiler the acia nk file contains the following information line 1 LINK COMMAND FILE FOR TEST PROGRAM line 2 Copyright c 1995 by COSMIC Software line 3 line 4 seg text b 0 000 n text program start address line 5 seg const a text constant after program line 6 seg data b 0x2000 data start address line 7 crts o startup routine line 8 acia o application program line 9 cx lib libi h11 C library if needed line 10 cx lib libm h11 machine library line 11 seg const b xtrdo vectors start address line 12 vector o interrupt vectors file line 13 def memory Q8 bss symbol used by startup line 14 de
17. MA NGABA LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E If your application calls a C library function you must include the header file that declares the function at compile time in order to use the proper return type and the proper function prototyping so that all the expected arguments are properly evaluated You do this by writing a preprocessor directive of the form include header name gt in your program where lt header_name gt is the name of the appropriate header file enclosed in angle brackets The required header file should be included before you refer to any function that it declares The names of the header files packaged with the C library and the functions declared in each header are listed below lt assert h gt Header file for the assertion macro assert lt ctype h gt Header file for the character functions isa num isalpha iscntrl isgraph isprint ispunct isspace isxdigit isdigit isupper islower tolower and toupper lt float h gt Header file for limit constants for floating point values lt gt Header file for input output registers Each register has an upper case name which matches the standard Motorola definition They are mapped at a base address defaulted to 0x1000 Specifics header files are provided for the MC68HC11K4 MC68HC11F1 and MC68HC11C0 respectively called iok4 h iof1 h and iocO h lt limits h gt Header file for limit constants of th
18. RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi VE Initialization of the bss section if any ROM into RAM copy if required nitialization of the stack pointer main or other program entry point call and An exit sequence to return from the C environment Most users must modify the exit sequence provided to meet the needs of their specific execution environment The following is a listing of the standard runtime startup file crts h11 included on your distribution media It does not perform automatic data initialization A special startup program is provided crtsi h11 which Is used instead of crts h11 when you need automatic data initialization The runtime startup file can be placed anywhere in memory Usually the startup will be linked with the RESET interrupt and the startup file may be at any convenient location Description of Runtime Startup Code L C STARTUP FOR MC68HCII 2 Copyright c 1995 by COSMIC Software 3 4 xdef exit __stext 5 xrerf main _ memory _ stack 6 7 switch bss 8 Ssbss 9 Switch text 10 _ stext 11 clra reset the bss 12 ldx 5055 start or bss 13 bra loop start loop l4 zbc1 15 staa D clear byte 16 MAX next byte 17 loop 18 px __memory up to the end 19 bne zbcl and loop 20 lds f stack initialize stack pointer 21 SL _main execute main 22 exit 43 bra exit and stay here 24 25 main is the
19. Terminate PCbugll session without confirming IRD Display ot trace MCU registers RESET addr MCU Hardware Reset with Existing or new reset vector RESTART option Restart PCbhugll with same or new option RM Modify MCU registers in window RS register value Set value of MCU register Stop user code execution SHELL command P Shell to DOS or execute DOS command SAVEM filename Save macro definitions in default or user file IT addr Trace user code TERM Xl Y1 X2 Y2 Simple windowed terminal emulator TYPE filename Display disk file in main window UNDEF symbol Undefine a symbol VER Display version number VERF ERASE addrl addr2 Verify that memory contains SFF VERF SET addrl addr2 value Verify that memory contains the value VERF filename memaddr Verify S record disk file against memory WAIT ms Wait for ms Special Key operations lt gt Send break channel lt CTRL gt P Toggle MCU memory write protect RTS line lt gt Attempt to re synchronise talker EVS BUFFALO Compatible commands These commands operate in a similar manner to the command of the same name the Motorola 68HCI1 EVS systems ASM BF BR G HELP MD MM NOBR RD RM pk enseirb 2004 v2 0 40 1 i 43 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik aL J pk enseirb 2004 2 0 41 1 1 42
20. code in the text section Function code is not to be altered or read as data External function names are published via xdef declarations Literal data such as strings float or long constants and switch tables are normally generated into the const section An option on the code generator allows such constants to be produced in the text section The compiler generates initialized data into the data section External data names are published via xref declarations Data you declare to be of const type by adding the type qualifier const to its base type is normally generated into the const section Data declared with the dir space modifier will be pk enseirb 2004 v2 0 52 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E generated into the bsct section Uninitialized data are normally generated into the bss section unless forced to the data section by the compiler option nobss Function calls are performed according to the following 1 Argaments are moved onto the stack from right to left Unless the function returns a double or a structure the first argument is stored in the d register if its size is less than or equal to the size of an int or in d and 2 x if its type is long or unwidened float 2 A data space address is moved onto the stack if a structure or double return area is required 3 The function is called via a jsr func instruction If the called is a
21. def __stack 0x00 defines a symbol stack equal to the absolute value OxOOff hex value The symbol qw stack is used by the startup routine to initialize the stack pointer By default and in our example the bss segment follows the data segment The crts o file contains the runtime startup that performs the following operations initialize the bss if any initialize the stack pointer call main or any other chosen entry point For more information see Chapter 3 Programming for MC68HC11 Environment Modifying the Runtime Startup After you have modified the linker command file you can link by typing clnk o 11 acia lnk Step 4 Generating S Records file Although acia h11 is an executable image it may not be in the correct format to be loaded on your target Use the chex utility to translate the format produced by the linker into standard formats To translate acia h11 to Motorola standard S record format chex acia hll acia hex Or chex acia hex 11 acia hex is now an executable image in Motorola S record format and is ready to be loaded in your target system Linking Your Application You can create as many text data and bss segments as your application requires For example assume we have one bss two data and two text segments Our link command file will look like tseg bsct 0 0 zpage start address var_zpage o file containing zpage variable seg text b 0 000 n
22. en savoir plus sur le d veloppement d applications bas es sur l utilisation du microcontr leur 8 bits 68HC1 1 Un microcontr leur 8 bits cela semble vraiment peu puissant et d pass par rapport aux processeurs 32 et maintenant 64 bits Mais ils trouvent largement leur place dans des applications de la vie quotidienne o l on n a pas besoin de MIPS et de MFLOPS micro onde lave vaisselle TV voiture domotique leur tude est donc toujours d actualit et reste un bon tremplin pour l tude de microcontr leurs plus puissants ColdFire de Motorola Durant votre carri re d ing nieur vous serez amen e atravailler sur des documents crits dans leur grande majorit dans la langue de Shakespeare Ce TP se base sur de nombreux documents crits en anglais que vous retrouverez dans les annexes et essaye de vous placer dans ce contexte professionnel Ce que vous avez pu voir sur le microprocesseur 68000 vous aidera s rement et toute analogie possible sera b n fique Nous verrons quelques moyens de d veloppement d applications 68HC11 en assembleur avec le langage l utilisation de biblioth ques d I O et la programmation multitache avec un noyau temps r el uC OS II en 377 ann e Ce TP requiert une connaissance de base sur le langage C et l architecture d un microprocesseur 68000 al ENSEIRB Ce texte a t r dig apartir d un rapport de stage IUT de Y Benaben 1998 99 que je tiens ici aremercier e
23. le programme d cho sur la RS 232 2 Cr er le fichier ping2 bat partir de pingl bat 3 Cr er le fichier de commandes ping2 kf pour l dition de liens partir de ping lkf Quelles sont les adresses de base pour le code les donn es initialis es et les donn es non initialis es Ex cuter le fichier ping2 bat Apr s correction des erreurs ventuelles vous devez avoir les fichiers ping2 map ping2 s19 ping2 o ping2 h11 Les erreurs ventuelles sont consign es dans le fichier ping2 err 4 Analyserle fichier de mapping ping2 map donnant entre autre la table des symboles Quel est le point d entr e du programme 5 A l aide de BUFFALO t l charger le fichier SRecord ping2 5 9 V rifier le bon fonctionnement du programme PING2 6 Le programme ping2 c est il portable dans un environnement standard UNIX pk enseirb 2004 v2 0 33 9 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 13 EX 4 ECHO SUR LA RS 232 EXECUTION DIRECTE DU PROGRAMME AU RESET EN MODE ETENDU R capitulatif PING3 Echo sur la liaison RS 232 Ex cution directe au reset LANGAGE MODE 68HC11 Bootstrap avec validation des acc s externes puis tendu RAM EXTERNE HIGH 8000 FFFF MONITEUR JBUG11 REPERTOIRE TP_68HC11 EX4 AUTRE HYPERTERMINAL Le but de ce TP est de reprendre le programme C ping1 c du TP1 en le faisant ex cuter directement au reset La RAM externe est en position RAM HIGH interrup
24. processes assembler listing files with the associated executable file to produce listing with updated code and address values clabs decodes an executable file to retrieve the list of all the files which have been used to create the executable For each of these files clabs looks for a matching listing file produced by the compiler le file If such a file exists clabs creates a new listing file la file with absolute addresses and code extracted from the executable file To be able to produce any results the compiler must have been used with the option Command Line Options clabs accepts the following command line options each of which is described in detail below clabs options file process files in the current directory only Default is to process all the files of the application S specifies the output suffix including the dot character if required Default is V be verbose The name of each module of the application is output to STDOUT file specifies one file which must be in executable format Return Status clabs returns success if no error messages are printed that is if all reads and writes succeed Otherwise it returns failure Examples For example the following command line clabs acia hll will output crts ls acia is pk enseirb 2004 v2 0 60 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Li Bi LS E vector ls and creates the fol
25. text program start address seg Const a Lext constant follow program seg data b 0x2000 data start address seg bss b 0x2500 bss start address URLs startup routine acia o main program modulel o application program text b OKFUO start new text section module2 0 application program module3 o application program cx lib libi h11 C library if needed cx lib libm h11 machine library seg const bOxffdo vectors start address Vector O interrupt vectors def __memory bss symbol used by startup pk enseirb 2004 v2 0 47 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E def stack 0x00ff stack pointer initial value In this example the linker will locate and merge crts o acia o and module1 o in a text segment at 0xe000 a data segment at 0x2000 and a bss segment if needed at 0x2500 zero page variables will be located at 0 0 The rest of the application module2 o and module3 o and the libraries will be located and merged in a new text segment at Oxf000 then the interrupt vectors file vector o in a constant segment at Oxffd6 Specifying Command Line Options You specify command line options to cx6811 to control the compilation process To compile and get a relocatable file named acia o type CX6811 acra c The v option instructs the compiler driver to echo the name and options of each program it calls The option inst
26. C source line interspersed in it Please note that the C source lines are commented in the assembly language file they start with As you use the C compiler you may find it useful to see the various actions taken by the compiler and to verify the options you selected The v option known as verbose mode instructs the C compiler to display all of its actions For example if you type Ee LE ev s the display will look like something similar to the following alax 66811 o GtempOo cxl SINGKANGSIT acia e cg6811 o ctempc cx2 ctempc cxl co6811 acia s ctempc cx2 The compiler runs each pass cp6811 the C parser cg6811 the assembly code generator co6811 the optimizer Step 2 Assembler The second step of the compilation is to assemble the code previously produced The relocatable object file produced is acia o cx6811 acia s Or ca6811 i cx h6811 acia s If you want to use directly the macro cross assembler The cross assembler can provide when necessary listings symbol table cross reference and more The following command will generate a listing file named acia ls that will also contain a cross reference ca6811 c 1 acia s Step 3 Linking This step consists in linking relocatable files also referred to as object modules produced by the compiler or by the assembler lt files gt o into an absolute executable file acia h11 in our example Code pk enseirb 2004 v2 0 45 A Fos D
27. CBUGII Avant d aborder la programmation du microcontr leur 68HC11 nous allons voir un peu plus d tail le fonctionnement du logiciel PCBUGI 1 PCBUGII est un petit logiciel qui permet de t l charger et d bugger gt des programmes que l utilisateur d sire faire ex cuter par le 68HC11 Mais comment proc de t on pour t l charger son programme dans la m moire du 68HC11 Lors de l criture d un programme en assembleur 68HC11 une directive d assemblage ORG adresse en hexad cimal permet de d finir l adresse de base du programme dans la m moire Il faut donc placer son programme dans une zone libre et inscriptible C est le cas de la RAM interne ou externe et de l EEPROM interne L EEPROM n cessite un protocole de programmation un peu plus complexe que la RAM mais l avantage est que le code du programme sera conserv m me si l alimentation du microcontr leur est coup e Le cas d un programme crit en langage volu type C peut se ramener au cas pr c dent sachant que l on pr cise l adresse de base de t l chargement lors de la phase d dition de liens Pour la suite 11 faut examiner le fonctionnement du microcontr leur En mode lt bootstrap gt il apparait une lt boot ROM gt en BF40 BFFF zone de m moire morte laquelle le processeur saute apr s le reset Cette m moire de boot pr sente dans la cartographie uniquement en mode bootstrap et special test contient une petite routine qui auto
28. CONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E This chapter describes each of the programming support utilities packaged and the debugging support available with the C cross compiler targeting MC68HC11 The following utilities are available chex translates object module format clabs generates absolutes listing clib builds and maintains libraries cobj examines objects modules The description of each utility tells you what tasks it can perform the command line options it accepts and how you use it to perform some commonly required operations At the end of the chapter are a series of examples that show you how to combine the programming support utilities to perform more complex operations The chex Utility You use the chex utility to translate executable images produced by clnk to one of several hexadecimal interchange formats These formats are Intel standard hex format and Motorola S record format You can also use chex to override text and data biases in an executable image or to output only a portion of the executable The executable image is read from the input file lt file gt Command Line Options chex accepts the following command line options each of which is described in detail below chex options file the argument file is a considered as binary file is the output address of the first byte f define output file format If is specified fi Intel hex format i
29. K K ck kk KK KK void write com unsigned char f KKCKCKCKCK kk kk kk kk kk kk kk kk kk Sk SGS SS kk ck kk ck k ck ck kckck kckck kc kc kck kc k ck k kk X KK KKK KK Kk KK KK KK KK k X K K K K K K K KOK K Kk K K K KOK KOK K kk ck kk k ck kk k ck kck ck KK kk KK KK Fonction AppTickInit a entree s rien y ZS sortie e rien my Description mu Initialisation de l interruption tick timer pour le noyau pe WE AO Emi 527 KKK KK KK KK Kk 1 lt Kk kk Kk k K K Kk K k K K kk K kk ck k ck ck k K K ck ckck ck kc Kk k kc k ck ck kk X KK KK Kk KAKAK KAKAK X K k K K K K K KOK K Kk Kk K KOK KOK KOK ck ck kk k ck kk k ck kk kk kk KK KK extern void AppTickInit void L utilisation de la biblioth que LIBHC11 n cessite l inclusion du fichier lt header libhc11 h et l dition de liens avec le fichier objet de la biblioth que LIBHC11 libhc11 o pk enseirb 2004 v2 0 21 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik aL a Bi Lo gt d Le squelette du programme C est ainsi le suivant includes libhell h tinclude void main vord 4 int 1 0 baudrate 9600 Exemple de programme C et d utilisation de l environnement Cosmic Le corps du programme source C fichier ping c est donn ci apr s faut noter l utilisation ici de la biblioth que LIBHC11 tinclude include sbtoro Hh void Main void 1 int 1 0
30. K KOK K Kk K K K KOK K kk kk ck kk k ck kk k ck kc kc k ck ck kk kk ko void put8A unsigned char KKK KK KK KK KK KK lt Kk lt X lt Kk k k Ck k k k K K Ck ck K K K ck kk ck K K K kc kck ck kc K k ck k kk kk X KKK KK KK KK kk CK kk Kk X Kk K K K K K K Kk K K K K KOK K ck K K K K k K k KOK KOK ck K k k k k k k k Fonction putlA i entree s valeur d un bit a ecrire dans le port A sortie e rien x Description 7 Ecriture d un bit dans le port sortie 9 Dits id f amp lt KK KK KK KK KK k X K K K K KAKAK KAKAK K K K KOK K K K k ck k kk k ck kk kk kck ck kk kk k kk KKK KK KK KK kk kk CK Ck Kk lt X X X k X K K K K k k K K K Kk K K K ck K k K K K k k KOK KOK KOK k ck k k k k k void putlA unsigned char unsigned char KKK KKK KK KK KK KAKAK X K K KOK K K K K K K Kk Ck K KOK KOK K kk ck k k k ck kk k ck k ck k kk kk kk KK f amp KKK Kk KK KK KK KK k X K k K K K K K KOK K KOK K K K KOK K kk KOK ck KOK k ck OK KOK ck kck kc KK KK KK ok Fonction baudrate und entree s valeur du baud rate de la RS 232 sortie e rien ar Description W I Configuration du port serie vitesse max 9600bps vitesse min 1200bps S KKK KKK Kk KAKAK KK kk k X kk K K K K K KOK K KOK K K K KOK KOK K k ck ck kck k ck kk k ck kck kc kk kk k kk KKK KK KAKAK KAKAK KAKAK K K K KOK K Kk Kk K KOK KOK K kk k kk k ck K KOK ck k ck k kk kk kk kx voi
31. Kk k k K K K K KOK KOK K K ck K Kk K ck KOK KOK ck ckck kk ck kk k KKK KK KK KK KAKAK Kk k K K XK K K KOK K KOK K K kCk kCk KOK k KOK KOK k ck OK KOK KOK KO KOK Ok K KK KK unsigned char getlE unsigned char pk enseirb 2004 v2 0 19 CENTRE CITE Ng rim umi ILLU TT awane MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik KKK KK KK KK kk Ck KK DS kk ck kk ck kck ck ck ckck kckck ck kckck ck kc kk kk X Fonction get8E zy JA entree s rien sortie e valeur du port E Description a7 Lecture de l etat du port E entree 8 bits au KKK KK KK KK KK Kk KC Ck Kk kk Kk k k K k K k K K kk K kk ck k ck ck k K K kc kck KOK K k kc k ck ck kk X KKK KK KK KKK KK KK Kk kk Kk k k k k K Kk K K kk K kk ck K K ck ck K K K ckck ck kc kck ck kc kk kk X unsigned char get8E x KKK Kk KK KK KAKAK X K k K K K K K KOK K Kk Uk K KOK KOK K kk k kk k ck K KOK ck k ck k kk kk kk ok KK KKK KK KK KK KK KK KK k X K K KOK K K K KOK K KOK K K K KOK KOK K KOK KOK OK k ck K KOK KOK KOK KK KK k kk Fonction put8A nu 5 valeur a ecrire dans le port A sortie e rien W I Description Ecriture dans le port sortie 8 bits WI KKK KK KK KKK KK kk kk kk kk X X kk K k K k K K kk K K KOK k ck ck K K K K KOK ck kc K k kc k ck kk koX KKK KK KAKAK KAKAK Kk K KOK K K
32. RF 020 read character with echo int getchar void phar while SCSR RDRF SCDR Le G a cts return putchar c Fonction Cosmic putchar PUT A CHARACTER TO SCI OUTPUT Copyright 1995 by COSMIC Software d include lt io h gt define TRDE 0x80 ZS output a character 2y int putchar char c 773 while SCSR amp TRDE SCDR if O else return 0 pk enseirb 2004 v2 0 64 Patrice Kadionik 5 iQR3 EIS i MH SI awan LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik ANNEXE 3 Pr sentation du format SRecord pk enseirb 2004 v2 0 65 TRE PE TAK CT Ya NGT LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik E L 8 FORMAT MOTOROLA An S record file consists of a sequence of specially formatted ASCII character strings An S record will be less than or equal to 78 bytes in length The order of S records within a file is of no significance and no particular order may be assumed The general format of an S record follow a type count address data checksum char 2 field These characters describe the type Of record 150 51 52 85 25 51 Soy OF s count A char 2 field These characters when paired and
33. T RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E You cannot call an interrupt function directly from a C function It must be connected with the interrupt vectors table NOTE The interrupt modifier is an extension to the ANSI standard Placing Addresses in Interrupt Vectors You may use either an assembly language program or a C program to place the addresses of interrupt handlers in interrupt vectors The assembly language program would be similar to the following example switch const xref handlerl handler2 handler3 Vector1 dc w handlerl vector2 dc w handler2 vector3 dc w handler3 end where handler and so forth are interrupt handlers A small C routine that performs the same operation is extern void handlerl handler2 handler3 void const vector handleri handler2 handler3 where handler1 and so forth are interrupt handlers Then at link time include the following options on the link line seg const bOxffd6 vector o where vector o is the file which contains the vector table This file is provided in the compiler package Interfacing C to Assembly Language The C cross compiler translates C programs into assembly language according to the specifications described in this section You may write external identifiers in both uppercase and lowercase The compiler prepends an underscore character to each identifier The compiler places function
34. UR 8 BITS 68HC11 Patrice Kadionik a Bi Li 8 En revanche EPROM utilis e est de 32 Ko permettant ainsi de mettre d autres programmes en EPROM L initialisation de la table des vecteurs doit se faire lors de la programmation de l EPROM 6 3 Commandes du moniteur BUFFALO Les commandes du moniteur BUFFALO sont similaires celles utilis es par PCBUGII et sont accessibles d s la mise en route du moniteur en tapant entr e ou help la capture d cran suivante montre l ensemble des commandes dont le r le est assez intuitif BUFFALO 2 4 Ex i EHMSERBE Bit User Fast Friendly Aid ta Logical Operation BSHCLILES CPU SE BUFFALO MONITOR PROGRAM EPROM 0000 TO z9FFF DEFAULT INTERNAL BAM 4 REGISTER ALLOCATION EEPROM TO EXTERNAL BAM SEE 0000 TO ASH zaddr Line asm disasm Same addr Prev addr T CTLJI Next addr CR Next opcode CTLA Quit zaddrl addrz data gt Block fill memory BR addr Set up bkpt table BULK Erase EEPRUM BULEALL Erase EEPROM and CONFIG CALL addr Call subroutine addr Execute code at addr PROCEED Continue execution EEMOD lt addrs lt addr gt Modify EEPROM range LOAD VERIFY T lt host dwnld command Load or verify S records HD taeddrl gt addrz Memory dump addr or addr Memory Modi w Same addr Prev addr T CTLI SPACE Next addr lt addrr 0 Compute offse
35. aUROEAL LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik ANNEXE 2 Pr sentation de Cosmic C C Cross Compiler User s Guide for MC68HC1 1 Resume pk enseirb 2004 v2 0 42 1 1 NG LIFE d LE MICROCONTROLEUR BITS 68HC11 Patrice Kadionik Bi TUTORIAL INTRODUCTION This chapter will demonstrate step by step how to compile assemble and link the example program acia c which is included on your distribution media Although this tutorial cannot show all the topics relevant to the COSMIC tools it will demonstrate the basics of using the compiler for the most common applications In this tutorial you will find information on the following topics Default Compiler Operation Compiling and Linking Generating Hex File Linking Your Application Generating Automatic Data Initialization Specifying Command Line Options Acia c Example file The following is a listing of acia c This C source file is copied during the installation of the compiler EXAMPLE PROGRAM WITH INTERRUPT HANDLING include lt io h gt buffer size transmit ready bit reception buffer read pointer write pointer define SIZE 128 define TDRE 0x80 T Le Authorize interrupts define 11 _asm cli n ZS Some variables char buffer SIZE char ptlec char ptecr oa 2 Character reception Loops until a character is received ny char getch void char c j wh
36. all buffer BSc progress Clears command line or terminates most commands in command line serve as a trace of the last four above the command line shows breakpoints and The four lines above the commands The fifth line error codes Possible error codes are D No error 1 error a MS or BF error 3 Talker communication failure For MS DOS batch files PCbugll terminates an error code can be checked via ERRORLEVEL after Monitor Commands The following is a summary of PCbugll commands COMMAND DESCRIPTION ASM addr mnej dir Call symbolic macro line assembler with option to auto insert mnemonic or directive BAUD rate Display or set serial baud rate addrl addr2 byte word Block fill memory with byte or word BL Display breakpoints BR addr macroname Display Set break point with optional macro execution CALL addr Execute the subroutine at addr CLRM Clear all command macros CLS Clear main window CONTROL Display or set CONTROL parameters CONTROL BASE BIN HEX DEC pk enseirb 2004 v2 0 Change default number base 38 Eum P NEN AM 12 Ge aimes ia LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik CONTROL BIOS Access serial COM port through BIOS calls CONTROL COLOR Set PCbhugll display colors CONTROL COLOUR Set PCbugll display colours CONTROL COMI Use COMI port CONTROL 2 Use COM2 port
37. bler options Cl pach Tor 118 108 co path for objects d gt define symbol ex prefix executable 6 create error file configuration file g code generator options i path for include create listing no do not use optimizer o optimizer options p gt parser options create only assembler file path for temporary files V verbose X do not execute gt select compiler options File Naming Conventions The programs making up the C cross compiler generate the following output file names by default See the documentation on a specific program for information about how to change the default file names accepted as input or generated as output program input file name output file name C Compiler Passes Cp681 1 lt file gt c lt file gt 1 cg6811 lt file gt 1 lt file gt 2 co6811 lt file gt 2 lt file gt s error listing lt gt lt file gt err assembler listing lt file gt c s lt file gt Is C header files lt gt Assembler ca6811 lt file gt s lt file gt 0 source listing lt file gt s file Is Linker cink lt file gt o name required Programming Support Utilities pk enseirb 2004 v2 0 55 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E chex file STDOUT clabs lt file h11 gt lt files gt la clib lt file gt name required cobj lt file gt STDOUT Generating Listings You can gene
38. c sscanf tolower gets memchr strcat toupper isalnum memcmp Strohr vprint f isalpha memcpy strcmp vsprintf Floating Point Library Functions acos cosh log sinh asin exp 10410 sprinti atan fabs modf sqrt atan2 floor pow sscanf atof fmod printf strtod ceil frexp scanf tan COS ldexp sin tanh Common Input Output Functions Six of the functions that perform stream output are included in both the integer and floating point libraries The functionalities of the versions in the integer library are a subset of the functionalities of their floating point counterparts The versions in the integer library cannot print or manipulate floating point numbers These functions are printf scanf sprintf sscanf vprintf and vsprintf Functions Implemented as Macros Five of the functions in the C library are actually implemented as macros Unlike other functions which if they do not return int are declared in header files and defined in a separate object module that is linked in with your program later functions implemented as macros are defined using define preprocessor directives in the header file that declares them Macros can therefore be used independently of any library by including the header file that defines and declares them with your program as explained below The functions in the C library that are implemented as macros are max min va arg va endand va start Including Header Files pk enseirb 2004 v2 0 57
39. ch of which is described in detail below cobj options file file specifies a file which must be in relocatable format or executable format d output in hexadecimal the data part of each section h display all the fields of the object file header n display the name size and attribute of each section I output in symbolic form the relocation part of each section S display the symbol table pk enseirb 2004 v2 0 62 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a an Li 8 X display the debug symbol table If none of these options is specified the default is hns Return Status cobj returns success if no diagnostics are produced i e if all reads are successful and all file formats are valid Examples For example to get the symbol table s alloc o symbols main 00000036 section text defined public outch 00000010 section text defined public buffer 00000000 section bss defined public _ptecr 00000000 section bsct defined public zpage _getch 00000000 section text defined public _ptlec 00000002 section bsct defined public zpage _recept 00000028 section text defined public pk enseirb 2004 v2 0 63 Ur geg LE MICROCONTROLEUR 8 BITS 68HC11 Li 8 TTA Fonction C Cosmic getchar CS GET CHARACTER FROM SCI INPUT Copyright 1995 COSMIC Software de include lt io h gt define RD
40. d baudrate unsigned int pk enseirb 2004 v2 0 20 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Hi L 8 KKK KK KK KK kk kk KAKAK KAKAK kk X X K K K K K Kk K Kk K K K K K kk ck K K ck K k K kck k KOK ck ck ck ck k k kk k KKK KK KK KK kk kk KK Ck kk lt X X X k K k K K Kk K Kk K K K K KOK K ck K K K kck k Kk KOK KOK KOK k K k k k k k Fonction read com P entree s valeur du caractere recu sur la RS 232 sortie e z caractere recu 1 0 si rien Description A Lecture d un octet sur le port serie i KKK KK KK KK KK KK KK k K K K K K kk K KOK kck K KOK K k ck k ck ck k k k ck kk k ck kck ck ck ck kk k kk KKK KK KK KKK KK KK lt Kk Kk Kk k k K k K Kk K K kk K kk ck kk ck k K K ck KOK KOK K K ck k kk kk X unsigned Char read com unsigned char 7 KKK lt X KK KK KK KK KK KK KK K K K KOK K KOK KOK K KOK K KOK KOK K KOK KOK K KOK KOK KO KOK OK K KK KK f KKCKCKCKCK k k k Ck Kk Kk Kk KK kk kk kk kk kk k ck k k ck k ck ckck ck kck kk k Fonction write com entree s valeur du caractere a emettre sur la RS 232 sortie e rien Description i Ecriture d un octet sur le port serie f KK KKK KK Kk KK KK KK KK Ck KAKAK K K K KOK K Kk K K K KOK KOK K kk k kk k ck kk k ck k ck k ck ck kk kk KK KKK Kk KAKAK KK KK k X K K K K K K K KOK K KOK K K K KOK KOK K KOK K KOK OK K KOK KOK KO
41. d in the library with the module name to which they belong lists the files in the library be verbose extracts the files in files that are present in the library into discrete files with the same names If no files are specified all files in the library are extracted At most one of the options c r t x may be specified at the same time If none of these is specified the t option is assumed pk enseirb 2004 v2 0 61 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E Return Status clib returns success if no problems are encountered Otherwise it returns failure After most failures an error message is printed to STDERR and the library file is not modified Output from the t s options and verbose remarks are written to STDOUT Examples To build a library and check its contents clib c libc one o two o three o clib t libc will output one o 0 three o To build a library from a list file clib ci list libc six o seven o where list contains files for the libc library one o two o three o four o five o The cobj Utility You use cobj to inspect relocatable object files or executable Such files may have been output by the assembler or by the linker cobj can be used to check the size and configuration of relocatable object files or to output information from their symbol tables Command Line Options cobj accepts the following options ea
42. data PACTL EQU 51026 Pulse ACC Control Register 1 DDRA7 0 Inputs 1 OUDUL ORG 5000 LDS SFF initialisation de la pile LDAA 580 DDRA PAT sortie PACTL CHENILLE LDAA 8 routine chenillard AR GCHE allume la LED JOR TEMPO routine de temporisation ROLA rotation vers la gauche d 1 DIL CMPA 128 on regarde si on est arrive a PAT BNE GCHE si non on reboucle LDAA 128 allume la LED PA7 DRTE pk enseirb 2004 v2 0 17 m N5Z I 23 LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E JOR TEMPO routine de temporisation RORA CMPA 8 on regarde si on est arrive PA3 BNE DRTE BRA CHENILLE on termine un cycle AR TEMPO LOY 20000 temporisation BCLE DEY CP Y 0 BNE BCLE RIO END Figure 9 Exemple d un programme assembleur 68HC11 Programmation en langage G n ralit s Le compilateur C crois de Cosmic Software est ici utilis Il est noter que l on peut aussi assembler des programmes crits en assembleur mais pour des raisons de commodit la solution pr c dente est pr f r e La production d un objet partir d un programme C 68HC11 est la suivante Edition du fichier source extension du fichier c obligatoirement Compilation du fichier source l aide de la commande CX6811 EXE c gt CX6811 v libhcll c Le fichie
43. du programme en m moire Le param tre macroname est facultatif 11 permet d ex cuter une macro pr alablement charg e lors d un point d arr t EEPROM Oladdrl addr2 permet de supprimer une plage EEPROM param tre 0 ou bien de la configurer en sp cifiant l adresse de d part et d arriv e EEPROM ERASE bulk permet d effacer partiellement ou dans son int gralit l EEPROM dont l tendue est d finie gr ce EEPROM addrl addr2 pk enseirb 2004 v2 0 13 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik G addr ex cute le programme l adresse addr HELP affiche toutes les fonctions de PCBUGII ainsi qu un commentaire LOADS filename permet de t l charger un fichier SRecord S19 m moire MD startaddr endaddr visualise la plage de m moire s tendant de startaddr endaddr MM addr modifie le contenu de la case m moire l adresse addr NOBR addr supprime le point d arr t plac l adresse addr QUIT Y quitte le logiciel PCBUGII RD rafra chit l affichage des registres dans la fen tre centrale RESTART permet de relancer PCBUGI I si une erreur de communication est apparue on peut aussi utiliser CONTROL R soit R B permet d envoyer un BREAK sur la liaison s rie La liste compl te de toutes les instructions ainsi que leur mode d emploi est disponible dans le manuel de PCBUG11 cf bibliographie et
44. e compiler lt math h gt Header file for mathematical functions acos asin atan atan2 ceil cos cosh exp fabs floor fmod frexp log log10 modf pow sin sinh sqrt tan and tanh lt setjmp h gt Header file for nonlocal jumps setjmp and longjmp lt Stdarg h gt Header file for walking argument lists va arg va end and va start Use these macros with any function you write that must accept a variable number of arguments lt stddef h gt Header file for types size t wchar t and ptraiff t lt stdio h gt Header file for stream input output getchar gets printf putchar puts and sprintf lt Stdlib h gt Header file for general utilities abs abort atof atoi atol div exit labs Idiv rand srana strtod strtol and strtoul lt string h gt Header file for string functions memchr memcmp memcpy memmove memset strcat strchr stremp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn and strstr Functions returning int C library functions that return int and can therefore be called without any header file since int is the default function return type that the compiler assumed by default are isalnum isaloha iscntrl isgraph isprint ispunct isspace isxdigit isdigit isupper islower sbreak tolower and toupper USING THE PROGRAMMING SUPPORT UTILITIES AND DEBUGGING SUPPORT pk enseirb 2004 v2 0 58 A Fos D LTH AEA LEG OCT RC LE MICRO
45. entry point into the user C program memory is an external symbol defined by the linker as the end of the bss section The start of the bss section is marked by the local symbol sbss Stack is an external symbol defined by the linker as an absolute value Lines 11 to 19 reset the bss section Line 20 sets the stack pointer You may have to modify it to meet the needs of your application Line 21 calls main in the user s C program pk enseirb 2004 v2 0 49 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi Li n Lines 22 to 23 trap a return from maing If your application must return to a monitor for example you must modify this line Performing Input Output in C You perform input and output in C by using the C library functions getchar gets printf putchar puts and sprintf The C source code for these and all other C library functions is included with the distribution so that you can modify them to meet your specific needs Note that all input output performed by C library functions is supported by underlying calls to getchar and putchar These two functions provide access to all input output library functions The library is built in such a way so that you need only modify getchar and putchar the rest of the library is independent of the runtime environment Function definitions for getchar and putchar are char getchar void Char putchar char e Accessing Inter
46. er peut tre aussi passif et d assembler en ligne le code ex cut par le microcontr leur En g n ral c est l outil qui va permettre de savoir si l on a sur une carte un probl me hard ou soft Il existe autant d mulateur qu il y a de processeurs existants C est un appareil cher gt 150 mais dont la rentabilit est faite en cas d un probl me pointu par exemple dans un syst me embarqu pour les t l communications plantage au bout de quelques jours en endurance sans raison apparente exp rience personnelle plus d un mois pour fixer le bug Pour l mulateur 68HC 11 toutes les fonctions d mulation se font en temps r el et l on peut configurer l mulateur dans tous les modes bootstrap special test single chip et extended L utilisateur peut galement choisir d utiliser l horloge de la carte cible Target ou bien l horloge interne de l mulateur Voici ci dessous l ensemble des configurations que l on peut effectuer sur le type de processeur Processor Configuration File Editor lt CT68HC11 CFG gt Processor Update Emulator Type Clock Single Chip 4 BSHCTIAT i Clock B Expanded Clock Target Clock _ _ EEPROM AOM EPROM fe File Save as X Enable lt Enable 11 Load Starting at oxB600 EI Starting at oxE 000 EI B Enable Figure 15 Ecran de confi
47. f __stack 0xO0ff stack pointer initial value You can create your own link command file by modifying the one provided with the compiler Here is the explanation of the lines in acia Ink lines 1 to 3 These are comment lines Each line can include comments They must be prefixed by the character line 4 seg text 0 000 n test creates a text code segment located at e000 hex address and sets the segment name to text line 5 seg const a text creates a constant segment located after the previous text segment line 6 seg data b0x2000 creates a data segment located at 2000 hex address line 7 exts o runtime startup code It will be located at Oxf000 code segment line 8 acia o the file that constitutes your application It follows the startup routine for code and data line 9 1ibi n11 the integer library to resolve references line 10 1ibm h11 the machine library to resolve references line 11 seg const 6 creates a new constant segment located at ffd6 hex address line 12 vectors o interrupt vectors file pk enseirb 2004 v2 0 46 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi bh 8 line 13 def __memory bss defines symbol memory equal to the value of the current address the bss segment This is used to get the address of the end of the bss The symbol memory is used by the startup routine to reset the bss line 14
48. grammable a t introduit pour pouvoir le reprogrammer par la suite car la carte m re est utilis e en projet de fin d tude la glue logique de la partie sp cifique du projet pouvant alors naturellement s incorporer dans le composant 1 4 Cartographie m moire de la carte m re La cartographie m moire mapping m moire du microcontr leur 68HC11Ax AO Al et AS est la suivante pk enseirb 2004 v2 0 8 CH eT Rec qe LA GE HAM 11h AE RW qu PRE pmr ___ unen decode A Fos D TRE PCR TALE E CTI Vu rU LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow an Li n 51700 S7FFF SEU 56000 geng 512 BYTES EEPROM 88500 BALI 2 BFAn ol SPECIAL MODES HOM INTERRUPT BFFF BFFF VECTORS SF000 ron la KBYTES NORMAL MODES INTERRUPT SFFFF FFFF VECTORS SINGLE EXPANDED BOOTSTRAP SPECIAL CHIP TEST AB BS M Mw Figure 4 Cartographie m moire du 68HC11 dans tous les modes de fonctionnement Eo Remarque il est important de noter que les acc s aux ressources internes RAM interne EEPROM registres sont prioritaires vis vis des acc s externes De plus la configuration d origine du bit IRV du registre HPRIO permet de rendre invisibles les acc s internes non refl t es sur le bus externe d adresses Le 68HCI1AI est ici utilis de 2 mani res Avec
49. guration de l mulateur CT68HC11 Size 512 Byte Size 0 pk enseirb 2004 v2 0 26 GE PACE LE CO RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik hit H Bi L mulateur 68HC11 poss de 64 Ko de m moire programme et supporte une fr quence d horloge jusqu 24 MHz soit 6 interne L mulateur permet gr ce un logiciel sp cifique de visualiser simultan ment dans des fen tres s par es l tat du microprocesseur la m moire les registres internes le code d sassembl la pile pointeur contenu et la ligne de commande L mulateur permet galement de visualiser le code source les variables du programme ainsi que l ex cution pas pas en mode Trace Une manipulation int ressante consiste muler un 68HC11Ax en mode bootstrap gt m moire mulateur avec le contr le de PCBUGI1 sur le port s rie On visualise ainsi sur la capture d cran ci dessous le programme du TALKER qui a t t l charg en RAM par PCBUGI I Disassembly lt Ctrl D gt gt BANA LDS HHHEB HAS LEID LDA 1 000 6F2C CLE AC n BABS CC3H2C LDD H3H2C HABE n72B STAA 2 Hl E72D STAB 20 4 HABF 8648 LDAA 40 HB11 Hb TAP 001 2 7EHH12 JHP 5 HB15 B61H2E LDAA SCSR 001 8 9420 ANDA 20 HB fh AVE BEQ 001 5 RTL B61H2F LDAA SCDR 1 43 COM 0020 8D44 BSR pb 0022 2R4F BPL 6473 0024 8D31 BSR HAS 6426 oF H2 8D2E BSR HR 0029 17 TEA Ri 8D2B ESR PASTA HRZ oF RGDA HH2D 81
50. ides full floating point support the floating point library If your application does not perform floating point calculations you can decrease its size and increase its runtime efficiency by including only the integer library Inserting Assembler Code Directly Assembler instructions can be quoted directly into C source files and entered unchanged into the output assembly stream by use of the _asm function This function is not part of any library as it is recognized by the compiler itself Linking Libraries with Your Program If your application requires floating point support you must specify the floating point library before the integer library in the linker command file Modules common to both libraries will therefore be loaded from pk enseirb 2004 v2 0 56 UT ES geg ELT LE MICROCONTROLEUR 8 BITS 68HC11 rw ow Bi LS E Patrice Kadionik the floating point library followed by the appropriate modules from the floating point and integer libraries in that order Integer Library Functions The following table lists the C library functions in the integer library _ asm iscntrl memmov strcpy abort isdigit memset strespn abs isgraph printr strlen atoi islower putchar strncat atol isprint puts strcmp calloc ispunct rand Strncpy div isspace realloc strpbrk eepcpy isupper sbreak strrchr eepera isxdigirt scanf strspn eepset labs set jmp strstr exit ldiv sprintf strtol free longjmp srand Strtoul getchar mallo
51. ier Srecord on utilisera la commande BUFFALO LOAD r ception du fichier sur la liaison s rie et pour le programme HYPERTERMINAL le menu Transfert gt Envoyer un fichier texte mission du fichier sur la liaison s rie Remarque Il est possible de lancer automatiquement le programme en EEPROM au reset de la carte v Au niveau hard en reliant les signaux en sortie du microcontr leur Rx et Tx de la liaison s rie ensemble par une r sistance de pull up Au niveau soft au reset en mode bootstrap envoyer le caract re BREAK au microcontr leur Normalement le microcontr leur s attend recevoir le caract re FF pour t l charger dans sa RAM interne partir de l adresse 0000 256 octets avant de faire un lt JMP 0 gt S il re oit le caract re BREAK il fait dans ce cas un lt JMP B600 gt c est dire un saut au d but du programme en EEPROM 4 quoi correspond le caract re BREAK au niveau de la liaison s rie RS 232 pk enseirb 2004 v2 0 31 ski LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 11 EX 2 ECHO SUR LA RS 232 UTILISATION DE LA BIBLIOTHEQUE LIBHC11 R capitulatif PINGI Echo sur la liaison RS 232 LANGAGE MODE 68HC11 Le but de ce TP est d crire un programme C qui r alise l cho de tout ce qui est recu sur la RS 232 On utilisera la biblioth que de fonctions LIBHC11 pour cela 1 Cr er le fichier ping c dont la trame vous est donn e En utilisant la biblio
52. iguration du microcontr leur 68HC1 1 3 Le 68HCI1 tant en mode bootstrap comment peut on autoriser les acc s externes 4 Qu est ce que le format SRecord 5 Quels sont les diff rentes m thodes de t l chargement d un objet SRecord en RAM interne ou externe ou en EEPROM 6 Comment peut on d finir la notion de temps r el 7 Qu est ce qu un noyau temps r el Quel est son utilit pk enseirb 2004 v2 0 30 J I NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 10 EX 1 ANALYSE D UN SOURCE ASM 68HC11 COMPARAISON AVEC L ASSEMBLEUR 68000 R capitulatif TSTIO Comparaison ASM 68HC11 ASM 68000 EEPROM LANGAGE Assembleur 68HC11 MODE 68HC11 1 Editer le fichier tstio asc Comparer les mn moniques des instructions 68HC11 avec celles des instructions 68000 Vous semble t il facile de ma triser l ASM 68HC11 connaissant l ASM 68000 O sont les difficult s 2 Quelle est l adresse de base de t l chargement du code objet en m moire Quel est ainsi le type de la m moire adress e Le programme est il perdu apr s une remise sous tension Que fait ce programme Remapper le programme source en m moire RAM l adresse de base 2000 3 Assembler le programme source avec l ex cutable ASMHC11 EXE ex cuter le batch go bat T l charger le SRecord g n r avec le moniteur BUFFALO Lancer le programme Remarquer que la sortie PA3 est utilis e par BUFFALO Pour t l charger le fich
53. ile ptlec ptecr ptlec p if ptlec amp buffer SIZE 7 ptlec buffer return Send a char to the SCI void outch char e character to be returned equal pointers loop get the received char put in in buffer pk enseirb 2004 v2 0 43 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi Li 8 while SCSR amp TDRE wait for READY SCDR send it ZS Character reception routine This routine is called on interrupt It puts the received char in the buffer uf interrupt void recept void DOOR cl ar interrupt ptecr SCDR get the char if ptecr gt amp buffer SIZE pur Ve in butrer 7 ptecr buffer L Main program S Sets up the SCI and starts an infinite loop of receive transmit void main void ptecr ptlec buffer initialize pointers BAUD 0x30 initialize SCI SCCR2 0x20 parameters for interrupt cl authorize interrupts for 7 deep Z outch getch get and put a char Default Compiler Operation By default the compiler compiles and assembles your program You may then link object files using cink to create an executable program As it processes the command line cx6811 echoes the name of each input file to the standard output file your terminal screen by default You can change the amount of i
54. ing command line compiles assembles the acia c C program creating the relocatable program acia o If the compiler finds an error in your program it halts compilation When an error occurs the compiler sends an error message to your terminal screen unless the option e has been specified on the command line In this case all error messages are written to a file whose name is obtained by replacing pk enseirb 2004 v2 0 54 GALES LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw RB Bi a n the suffix c of the source file by the suffix err An error message is still output on the terminal screen to indicate that errors have been found If one more command line arguments are invalid cx681 1 processes the next file name on the command line and begins the compilation process again The example command above does not specify any compiler options In this case the compiler will use only default options to compile and assemble your program You can change the operation of the compiler by specifying the options you want when you run the compiler To specify options to the compiler type the appropriate option or options on the command line as shown in the first example above Options should be separated with spaces You must include the or that is part of the option name Compiler Command Line Options The cx6811 compiler accepts the following options cx6811 options files a assem
55. isateur dispose des ressources externes qui sont une RAM et une ROM externes de 32 Ko Des ports du 65HC11 sont alors attribu s aux fonctions d interfacage de composants ext rieurs Le PORT C est multiplex selon la valeur du signal AS le PORT C est soit le bus bidirectionnel des donn es DO D7 soit le poids faible du bus d adressage 16 bits 7 Le d multplexage est confi au circuit 741 5573 Le PORT B est le poids fort du bus d adressage A8 A15 L adressage sur 16 bits permet donc d adresser directement 64 Ko pk enseirb 2004 v2 0 7 J I Ng LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 1 3 D codage d adresse Le d codage d adresse est r alis par un circuit programmable ALTERA dont le sch ma symbolique est le suivant uma pn Figure 3 Sch ma du d codage d adresse On peut remarquer que le sch ma comporte un d codeur d adresse 74LS138 ainsi qu un circuit logique destin activer les CS des bo tiers m moire et la broche R W de la RAM On remarque galement qu une entr e suppl mentaire appel e MAP reli e une porte XOR a t rajout e afin de remplacer la m moire RAM par la m moire ROM et vice versa selon le programme implanter dans la page d adresse 8000 FFFF La valeur de MAP est fix e par un interrupteur MAP sur la carte m re Un composant pro
56. l annexe 6 T l chargement d un programme objet avec PCBUGII Lorsque l utilisateur d sire t l charger un programme dans la RAM ou l EEPROM de la carte m re il doit proc der comme suit Effectuer un RESET sur la carte cible Lancer PCBUGII QS Remarque le fonctionnement de PCBUGII sous DOS ne n cessite pas de configuration particuli re de l ordinateur En revanche l utilisation sous Windows 95 98 n cessite les configurations suivantes pas de contr le de flux mat riel pour le port de communication COMI ou COM2 et sensibilit d attente basse dans l onglet propri t e divers gt du programme PCBUG 11 Dans le cas d un t l chargement en EEPROM taper au pr alable les commandes suivantes EEPROM B600 B7FF si l EEPROM est situ e de l adresse B600 B7FF pk enseirb 2004 v2 0 14 1 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik EEPROM ERASE BULK permet d effacer Nous pouvons ainsi v rifier si l op ration a t r ussie en tapant MD B600 B7FF on ne doit voir que des octets FF QS Remarque importante si la programmation de la m moire EEPROM n est pas correcte il est possible soit qu elle ne se trouve pas aux adresses B600 B7FF soit que le registre de protection en criture BPROT pr sent sur les 6SHCIIEx F1 ait t configur pour prot ger l EEPROM Pour r soudre ce probl me il faut apr s avoir lanc PCBUG I1
57. le logiciel PCBUG11 de Motorola on travaille en mode bootstrap puis en mode special test Ceci permet de d verminer lt d bugger le code du programme tester par l interm diaire d un jeu de commandes voir annexe 6 Le programme test sera ensuite mis en ROM apr s la configuration du processeur en mode tendu lui conf rant ainsi une autonomie totale Avec le moniteur BUFFALO lt Bit User s Fast Friendly Aid to Logical Operation gt on travaille en mode tendu puisque le moniteur est programm dans l EPROM externe Le moniteur par l interm diaire d un jeu de commandes voir annexe 7 permet alors le d buggage gr ce un simple terminal ou un mulateur de terminal sur ordinateur Nous verrons plus en d tail comment nous utilisons ces 2 logiciels par la suite Il faut noter que le jeu de commandes de ces 2 logiciels est semblable celui du kit 68000 Motorola quel que soit le type de ses processeurs propose un moniteur avec les m mes commandes ce qui facilite la vie de l utilisateur en passant d un processeur un autre pk enseirb 2004 v2 0 9 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 2 PRESENTATION DE LA CARTE D ENTREES SORTIES Le microcontr leur 65HC11Ax en mode tendu ne poss de que 2 ports libres le PORT A et le PORT E Le PORT E ne pose pas de probleme particulier puisque tous les bits du PORT E sont accessibles en entr e la fonction de conversion A N n
58. lowing files crts la acia la vector la The following command line clabs acia hll will generate crts Ix acia Ix Vector X The clib Utility clib builds and maintains object module libraries clib can also be used to collect arbitrary files in one place library is the name of an existing library file or in the case of replace or create operations the name of the library to be constructed Command Line Options clib accepts the following command line options each of which is described in detail below ik r clib options lt library gt lt files gt creates a library containing files Any existing library of the same name is removed before the new one is created deletes from the library the zero or more files in files takes object files from a list You can put several files per line or put one file per line Each lines can include comments They must be prefixed by the character If the command line contains files then files will be also added to the library when a library is built with this flag set all the modules of the library will be loaded at link time By default the linker only loads modules necessary for the application in an existing library replaces the zero or more files in files If no library library exists create a library containing files The files in files not present in the library are added to it lists the symbols define
59. n far function the calling sequence is different It is detailed in the next paragraph 4 The arguments to the function are popped off the stack Data Representation Data objects of type char are stored as one byte Char representation Data objects of type short int and 16 bits pointers are stored as two bytes more significant byte first Short Int 16 bits pointer Data objects of type ong and 32 bits pointers are stored as four bytes in descending order of significance Long 32 bits pointers Data objects of type float and double are represented as for the proposed IEEE Floating Point Standard four bytes for float or height bytes for double stored in descending order of significance The IEEE representation is most significant bit is one for negative numbers and zero otherwise the next eight bits are the characteristic biased such that the binary exponent of the number is the characteristic minus 116 for float or 1022 for double the remaining bits are the fraction starting with the weighted bit If the characteristic is zero the entire number is taken as zero and should be all zeros to avoid confusing some routines that do not process the entire number Otherwise there is an assumed 0 5 assertion of the weighted bit added to all fractions to put them in the interval 0 5 1 0 The value of the number is the fraction multiplied by 1 if the sign bit is set multiplied by 2 raised to the exponent pk enseirb
60. n sur les registres du 68HC11 On peut s en apercevoir en autre par la banni re BUFFALO 3 2 int Bit User Fast Friendly Aid to Logical Operation Au lieu de BUFFALO 3 4 ENSEIRB pk yb Bit User Fast Friendly Aid to Logical Operation 68HC11 CPU A amp E series 8K BUFFALO MONITOR PROGRAM EPROM 8000 TO S9FFF EXTERNAL RAM 32K 0000 TO 7FFF EEPROM B600 TO SB7FF DEFAULT INTERNAL RAM amp REGISTER ALLOCATION Si tel est le cas pr venir aussit t l enseignant qui d validera le moniteur BUFFALO en ROM interne pour pouvoir faire les TP sinon certaines manipulations seront impossibles L outil PCBUGI11 ne marche pas sur des PC de fr quence sup rieure 300 MHz et sous Windows NT En cons quence on utilisera l outil JBug11 qui poss de une interface Windows faisant la m me chose que PCBUG11 et compatible au niveau des commandes en ligne pk enseirb 2004 v2 0 28 PAR LE CU RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Li Bi LS E PARTIE II MANIPULATIONS pk enseirb 2004 v2 0 29 5 1 23 GE PCR LE CT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow an Lii E 9 QUESTIONS DE SYNTHESE A l issue de la lecture de ce TP vous devriez pouvoir r pondre ces quelques questions 1 Pr ciser les diff rences existant entre un microprocesseur et un microcontr leur 2 Pr ciser les diff rents modes de conf
61. nal Registers The type modifier port may be used on a data object in conjunction with an absolute address to improve access to an internal register These input output registers are seen as memory locations but bit instructions are inoperative on extended addressing mode The port type modifier instructs the compiler to load the base address indirectly allowing efficient bit instructions to be used When the absolute address is specified the base address loaded is obtained from the upper bits of the full address 0x1000 for an address equal to 0x1021 The PORTB register may be declared port char PORTB 0x1004 The port modifier may be omitted when the register is accessed as bytes rather than bits All registers are declared in the io h file provided with the compiler This file should be included by a Finelude 10 1 in each file using the input output registers Three separate files ioc0 h iof1 h and iok4 h are provided for the special 68HC11C0 68HC11F1 and 68HC11K4 processors They do not use the same same of registers than the standard family All the register names are defined by assembly equates which are made public This allows any assembler source to use directly the input output register names by defining them with an xref directive All those definitions are already provided in the io s file which may be included in an assembly source by a include io s All these header files assume a default location for the input output
62. nformation the compiler sends to your terminal screen using command line options as described later According to the options you will use the following files recognized by the COSMIC naming conventions will be generated file s Assembler source module file o Relocatable object module file h11 input e g libraries or output e g absolute executable file for the linker Compiling and Linking To compile and assemble acia c using default options type 6611 acia e The compiler writes the name of the input file it processes The result of the compilation process is an object module named produced by the assembler We will now show you how to use the different components Step 1 Compiling pk enseirb 2004 v2 0 44 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E The first step consists in compiling the C source file and producing an assembly language file named acia s cx6811 s acia c The s option directs cx6811 to stop after having produced the assembly file acia s You can then edit this file with your favorite editor You can also visualize it with the appropriate system command type cat more For example under MS DOS you would type type acia s If you wish to get an interspersed C and assembly language file you should type CX6811 l acia c The option directs the compiler to produce an assembly language file with
63. pplication AN1060 pour le fonctionnement en mode bootstrap Application Snapshot AS 67 pour le fonctionnement en mode sp cial test sous PCBUGII Logiciel PCBUGII version 3 42 et son manuel complet lt M68HC11 PCBUGII USER S MANUAL gt M68PCBUGI I D Manuel lt HC11 EVALUATION SYSTEM OPERATIONS MANUAL gt qui donne la liste des commandes du moniteur BUFFALO Programme BUFFALO disponible pour toutes les versions du 68HC11 t l chargeable l adresse suivante 0 Software langage Version d valuation et manuel complet lt C Cross Compiler User s Guide for Motorola 8 11 gt de COSMIC Software t l chargeables l adresse suivante http www cosmic us com Note d application lt COSMIC V4 1x 68HC11 C Compiler Package gt D Emulateur Pathfinder 11 pk enseirb 2004 v2 0 71 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik Hi E CUT Fy Pi Y Manuel lt Embedded development systems USER MANUAL gt de ASHLING Microsystems Ltd l adresse du site internet est http www ashling com rubrique CT68HC11 Microprocessor Development System for windows pk enseirb 2004 v2 0 72
64. r objet a t cr pour l exemple libhcll o Un fichier d erreur est ventuellement cr pour l exemple libhc 1 err Edition de liens avec les autres fichiers objets ventuels On cr era pour cela un fichier de commandes commande CLNK EXE extension du fichier de commandes LKF Production du fichier SRecord final commande CHEX EXE T l chargement dans la carte mere Un exemple complet est donn ci apr s On se r f rera l annexe 8 pour de plus amples explications pk enseirb 2004 v2 0 18 h Fe GE PCR TAK C NOCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik a Bi L 8 gar id Y Biblioth que LIBHC11 de fonctions C de contr le de la carte d entr es sorties Une biblioth que de fonctions C de contr le de la carte d entr es sorties ainsi que de gestion de la liaison s rie a t crite Cela permet d crire des programmes plus clairs et mieux structur s Les sp cificit s mat rielles sont aussi gomm es c est dire que cette biblioth que joue un peu le r le de lt driver gt Voici la description des fonctions et leur prototype KK KKK KK Kk KAKAK KK KK kk K k K K K K K KOK K Kk Kk K KOK KOK K kk ck kk k ck K KOK ck k ck ck ck ck kk kk ok KKK KK KK KK KAKAK X K K KOK K K K KOK K KOK K K K KOK kk kk k kk k ck K KOK ck k ck k ck kc kk kk ko Fonction tempo S SS entree s duree de la tempo en ms Ay d sor
65. rate listings of the output of any or all the compiler passes by specifying the option to cx6811 You can locate the listing file in a different directory by using the cl option The example program provided in the package shows the listing produced by compiling the C source file acia c with the option CX6811 l acia c Generating an Error File You can generate a file containing all the error messages output by the parser by specifying the e option to cx6811 For example you would type CX6811 e prog c The error file name is obtained from the source filename by replacing the c suffix by the err suffix Return Status cx6811 returns success if it can process all files successfully It prints a message to STDERR and returns failure if there are errors in at least one processed file Examples To echo the names of each program that the compiler runs cx6811 v file c To save the intermediate files created by the code generator and halt before the assembler cx6811 s file c C Library Support This section describes the facilities provided by the C library The C cross compiler for MC68HC11 includes all useful functions for programmers writing applications for ROM based systems How C Library Functions are Packaged The functions in the C library are packaged in three separate sub libraries one for machine dependent routines the machine library one that does not support floating point the integer library and one that prov
66. record field is S8 0x5338 The address field contains the starting execution address and is interpreted as 3 byte address There is no data field The type of record field is S9 0x5339 The address field contains the starting execution address and is interpreted as 2 byte address There is no data field Shown below is a typical S record format file 500600004844521 S1130000285F245r2212226A000424290008237C2A pk enseirb 2004 v2 0 67 1 1 NG ES a LE MICROCONTROLEUR 8 BITS 68 11 Patrice Kadionik 1 Hi rt gt S11300100002000800082629001853812341001813 5113002041E900084E42234300182342000824A952 5107003000144 492 S5030004F8 59030000 The file consists of one 50 record four S1 records S5 record and an S9 record The SO record is comprised as follows S0 S record type 50 indicating it is a header record 06 Hexadecimal 06 decimal 6 indicating that six character pairs or ASCII bytes follow 00 00 Four character 2 byte address field zeroes in this example 48 ASCII D and P HDR 1B The checksum The first Sl record is comprised as follows oul S record type Sl indicating it is a data record to be loaded at a 2 byte address 13 Hexadecimal 13 decimal 19 indicating that nineteen character pairs representing a 2 byte address 16 bytes of binary data and a 1 byte checksum follow 00 00 Four character 2 byte add
67. registers depending on the actual target This default value be changed by defining the C symbol BASE by a define directive before the header file include define BASE 0x1000 include lt io h gt The default value of 0x1000 for the register starting address as defined by the file lt io h gt is changed to 0 NOTE The port modifier is an extension to the ANSI standard Inserting Inline Assembly Instructions pk enseirb 2004 v2 0 50 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E The _asm function inserts inline assembly code in your C program The syntax is asm String constant arguments The string constant argument is the assembly code you want embedded in your C program arguments follow the standard C rules for passing arguments The string you specify follows standard C rules For example carriage returns can be denoted by the n character For example to produce the following assembly sequence 1000h txs Jsr _main you would write _asm xgdx naddd 1000h nxgdx ntxs njsr _main n NOTE The argument string must be shorter than 512 characters If you wish to insert longer assembly code strings you will have to split your input among consecutive calls to asm To copy a value in the condition register you write asm tbaNntapNMn varcc The varcc variable is passed in the d register as a fi
68. ress field hexidecimal address 0 0000 where the data which follows is to be loaded 28 24 22 12 22 6 00 04 24 29 00 08 23 7C Sixteen character pairs representing the actual binary data 2A The checksum The second and third Sl records each contain 0x13 19 character pairs and are ended with checksums of 13 and 52 respectively The fourth S1 record contains 07 character pairs and has a checksum of 92 The S5 record is comprised as follows S record type 55 indicating it is a count record indicating the number of S1 records 03 Hexadecimal 03 decimal 3 indicating that three character pairs follow 00 04 Hexadecimal 0004 decimal 4 indicating that there are four data records previous to this pk enseirb 2004 v2 0 68 Ur re aksa ci ERN MEAM LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik J Hi Ce F8 The checksum The 59 record 15 comprised as follows 32 S record type 59 indicating it is termination record 03 Hexadecimal 03 decimal 3 indicating that three character pairs follow 00 00 The address field hexadecimal 0 decimal 0 indicating the starting execution address FC The checksum pk enseirb 2004 v2 0 69 A iP DAE ees LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik J Hi Ce FORMAT INTEL Intel HEX ASCII format takes the form
69. rise le t l chargement de 256 octets depuis le port s rie vers la RAM partir de l adresse 0000 En effet ce programme en boot ROM configure la liaison s rie 9600 b s 1 bit de start 8 bits de donn es 1 bit de stop pas de contr le de flux ni de parit Le programme de boot offre galement la possibilit de t l charger les 256 octets une vitesse de 1200 b s par l interm diaire d une routine interne de la ROM appel e autobaud qui d tecte la vitesse du t l chargement gr ce la r ception du caract re FF C est donc ce moment l que le logiciel PCBUGII envoie un petit programme de 192 octets environ qui est appel TALKER Comme son nom l indique ce petit programme va permettre de communiquer avec l ordinateur h te et ainsi d ex cuter les commandes de PCBUGI 1 voir annexe 5 Le logiciel PCBUGI1 pr sente l interface graphique suivante pk enseirb 2004 v2 0 12 GALES LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik er EEN TY PCBUG342 Ax lel Total bytes loaded 8246 Total bytes written 50246 otal bytes loaded 8278 Total bytes written 50024 CBBB 4F CLR GAN CEFHBH La H Popp CHB4 2883 BR SAAT GANG AYAN STAR 500 8 CAAS 08 CHH HCFB02 CPA HG Pop GANG 26F8 BNE CHAGE BEHHFF LDS lt Hii BDCB 1 JSR 50B01 6GH14 2HFE BR 56914 CB16 3C PSH Chi 3C FSHA PC ACCA ACCE Hi Y CCR SESHIMZUC SP MCU 68HCii g SABAN 540 52G 1000 50100 548
70. rst argument The asm sequence then transfers the low byte from the b register to the a register then to the condition register asm does not perform any checks on its argument string Only the assembler can detect errors in code passed as argument to an asm call _ can be used in expressions if the code produced by asm complies with the rules for function returns For example if _asm tpa ntab n amp 0 010 allows to test the overflow bit That way you can use asm to write equivalents of C functions directly in assembly language NOTE The argument string is added as is to the code during the compilation The optimizer does not modify the specified instructions unless the a option is specified to the code generator Writing Interrupt Handlers A function declared with the type qualifier interrupt is suitable for direct connection to an interrupt hardware or software interrupt functions may not return a value interrupt functions are allowed to have arguments although hardware generated interrupts are not likely to supply anything meaningful When you define an interrupt function the compiler uses the rti instruction for the return sequence You define an interrupt function by using the type qualifier interrupt to qualify the type returned by the function you declare An example of such a definition is interrupt void it_handler void pk enseirb 2004 v2 0 51 A Fos D LTH AEA LEG OC
71. ructs the compiler driver to create a mixed listing of C code and assembly language code in the file acia ls To perform the operations described above enter the command QGXOSIL ex L Gne When the compiler exits the following files are left in your current directory the C source file acia c the C and assembly language listing acia Is the object module acia o It is possible to locate listings and object files in specified directories if they are different from the current one by using respectivally the cl and co options Ox6811 cl mylist co myob L This command will compile the acia c file create a listing named acia ls in the mylist directory and an object file named acia o in the myobj directory cx6811 allows you to compile more than one file The input files can be C source files or assembly source files You can also mix all of these files If your application is composed with the following files two C source files and one assembly source file you would type ex6ell v Starts getchar c This command will assemble the start s file and compile the two C source files PROGRAMMING FOR MC68HC11 ENVIRONMENTS Modifying the Runtime Startup The runtime startup module performs many important functions to establish a runtime environment for C The runtime startup file included with the standard distribution provides the following pk enseirb 2004 v2 0 48 A Fos D LTH AEA LEG OCT
72. s produced If m is specified fm Motorola format is produced If 2 is specified f2 Motorola format with S2 records is produced Default is to produced Motorola S Records fm Any other letter will select the default format h do not output the header sequence if such a sequence exists for the selected format h insert in the header sequence if such a sequence exists for the selected format m output maximum data bytes per line Default is to output 32 bytes per line n gt output only segments whose name is equal to the string Up to twenty different names may be specified on the command line If there are several segments with the same name they will all be produced 0 write output module to file The default is STDOUT Return Status chex returns success if no error messages are printed that is if all records are valid and all reads and writes succeed Otherwise it returns failure Examples pk enseirb 2004 v2 0 59 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi LS E The file hello c consisting of char p hello world when compiled produces the following the following Motorola S record format chex hello o S00A000068656C6C6F2E6F44 S1110000020068656C6C6F20776F726C640090 S9030000FC and the following Intel standard hex format chex fi hello o 05000000020068656C6C6F20776F726C640094 00000001FF The clabs Utility clabs
73. t CR Quit MOVE ssl gt lt gt zd Block move OFFSET arg gt Offset for download PM P Y X A B C 5 Register modify STOPAT addr Trace until addr I tn Trace n instructions TH Transparent mode CTLA exit CTLB send bre CTLW Wait CTLX DEL Abort CR Repeat last cud 00 02 37 connect ANSI 9600 8 M 1 D fi Captures Figure 14 Moniteur BUFFALO en cours d utilisation Imprimer l cho Le programme source du moniteur BUFFALO est disponible chez MOTOROLA pour diff rentes versions du 68HC 11 voir bibliographie S pk enseirb 2004 v2 0 25 J I Ng LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik rw ow Bi Li La configuration du moniteur consiste sp cifier le d but de la zone le moniteur sera implant EPROM en g n ral le d but de la RAM interne la EEPROM et les registres L assemblage se fait avec ASMHCII EXE La description compl te des commandes du moniteur BUFFALO est donn e dans l annexe 7 7 UTILITE D UN EMULATEUR L mulateur CT68HC11 est un appareil con u pour muler la s rie de microcontr leurs 68HC11 pilote en temps r el l ensemble des signaux du microcontr leur et permet donc d ex cuter et de d bugger un programme t l charg dans l mulateur ou sur la carte cible C est un alli lors de la mise au point car il vite par exemple programmer chaque fois une EPROM avec la nouvelle version de programme test
74. t qui est sorti de l ENSEIRB en 2002 P Kadionik 04 03 03 pk enseirb 2004 v2 0 3 1 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik PARTIE I PRESENTATION GENERALE pk enseirb 2004 v2 0 4 1 1 NG LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik BLAA 1 1 PRESENTATION LA CARTE ENSEIRB 68HC11 1 1 Caract ristiques du microcontr leur 65HC 11 Le processeur employ est un microcontr leur 68 8 bits de Motorola dont les caract ristiques essentielles sont r sum es sur le sch ma suivant voir annexe 2 MODA MOOB LIR Verpy EXTAL TAG KIRO 8 KBYTES MODE CONTROL INTERRUPT LOGIC CLOCK LOGIC PERIODIC INTERRUPT BUS EXPANSION ADDRESS DATA ADDRESS E TIMEA SYSTEM AD CONVERTER STROBE AND HANDSHAKE PARALLEL IO 5 5 E lt T 2 CONTROL re ESE Ss BONDED ON 48 PIN VERSION A3 BOCK Figure 1 Architecture interne du 68HC11 Les caract ristiques de l ensemble des microcontr leurs de la famille 68HC11 sont pr sent es dans le document donn en annexe 1 On y trouvera aussi la liste exhaustive de l ensemble des documents de r f rence On peut souligner les l ments suivants microcontr leur en technologie HCMOS 5Ko de ROM 512 octets de EEPROM pk enseirb 2004 v2 0 5 5 1 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 256 octe
75. teur MAP pour pouvoir configurer la table des vecteurs Il faut noter ici qu en version finale le programme est mis EPROM ce qui reviendrait remplacer du moniteur BUFFALO par celle contenant le programme L utilisation de la RAM ici facilite la mise au point l Recopier sous D TP_68HC1 1 EX4 le fichier ping c sous le nom ping3 c Analyser le fichier crts s Quel est son r le Quel est l tiquette de point d entr e du programme PING3 Analyser le fichier batch ping3 bat Regarder le fichier d initialisation de la table des vecteurs vector c Retrouver le point d entr e du programme PING3 Analyser le fichier de commandes d dition de liens ping3 kf Quelles sont les adresses de base pour le code les donn es initialis es et les donn es non initialis es Quelle est l adresse de base du tableau const vectab A quelle adresse se situe alors le point d entr e au reset Est ce normal L ordre de chargement des objets o est il important dans le fichier pr c dent Ex cuter le fichier ping3 bat Analyser le fichier de mapping ping3 map Quelle est l adresse du point d entr e du programme pk enseirb 2004 v2 0 34 A Fos D LTH AEA LEG OCT RC LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik ett Less ce Sas 9 Configurer la carte en mode bootstrap Utiliser JBUGII Valider les acc s externes afin de pouvoir acc der la RAM externe de 8000 SFFFF
76. th que LIBHC11 r aliser le programme d cho sur la RS 232 2 Regarder le fichier ping bat fichier batch pour cr er le fichier SRecord ping s 9 Expliquer les diff rentes tapes ex cut es 3 Analyser le fichier de commandes ping kf pour l dition de liens Quelles sont les adresses de base pour le code les donn es initialis es et les donn es non initialis es Ex cuter le fichier pingl bat Apr s correction des erreurs ventuelles vous devez avoir les fichiers ping map pingl sI9 pingl o pingl h11 Les erreurs ventuelles sont consign es dans le fichier pingl err 4 Analyser le fichier de mapping ping map donnant entre autre la table de symboles Quel est le point d entr e du programme 5 Regarder le fichier SRecord ping 1 519 et retrouver les diff rents champs du fichier 6 A l aide de BUFFALO t l charger le fichier SRecord pingl s 9 V rifier le bon fonctionnement du programme PING1 pk enseirb 2004 v2 0 32 9 1 42 LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik 12 EX 3 ECHO SUR LA RS 232 UTILISATION DE LA BIBLIOTHEQUE D E S COSMIC R capitulatif PING2 Echo sur la liaison RS 232 LANGAGE MODE 68HC11 Le but de ce TP est de r crire le programme C pr c dent en utilisant la biblioth que de fonctions d E S de Cosmic pour cela 1 Cr er le fichier ping2 c partir du fichier pr c dent ping c En utilisant la biblioth que d E S Cosmic r aliser
77. tie e rien Description Temporisation en ms Utilise la sortie Output Compare 1 KKK KK KK KKK KK KK KK Kk kk Kk k k k k k k K K kk ck kk ck k ck ck K K K ck ckck ck kc kck kc k kk kk X f amp KKK KK KK KK kk kk kk kk kk K K KOK K KOK K K K KOK KOK K kk k kk kck kk k ck k ck k ck ck kk kk K void tempo unsigned int KKK KK KK KK KK KK KK KK KK IK I KK KK KK KK KK KK KK KK KK KK kK KKK KK KK KK KK KK KK KK KK KK X K K k K K Kk K Kk KK KK K K K ck ck K K KOK KOK ck ck ko k ko ERARI Fonction getlA W I 2 entree s numero du bit a lire du port A sortie e valeur du bit autres bits mis a 0 Description Lecture de l etat d un bit du port entree KKK KK KAKAK X K K KOK K K K KOK K AKK AKA kCk kk k ck KAKAK kk k ck kck ck kk kk k kk KKCKCKCKCK kk kk 1 lt Ck KK kk X Kk K K K K Kk k kk KC K K AKA kk kk k ck ck ck ck k ck kc k kk k unsigned char getlA unsigned char KK KKK KK Kk KAKAK KK KK k X K k K K K K K K K K Kk K K K KOK K kk k ck ck k k k ck kk kk kck ck kk kk kk ok KKK KK KAKAK KAKAK Kk k X K K k K KOK K Kk K K K KOK KOK K kk KAKAK kk k ck k ck kck ck kk kk KK Fonction getlE Jo entree s numero du bit a lire du port E sortie e valeur du bit autres bits mis 0 Description Lecture de l etat d un bit du port E entree KK KK Ck KK Ck Kk X K K K K K
78. tion en assembleur 68H C11 17 5 2 FProprammaton en langage 18 Wei 18 Bibliotheque LIBHC11 de fonctions C de contr le de la carte d entr es sorties 19 4 Exemple de programme C et d utilisation de l environnement Cosmic C ee 22 6 Utilisation du moniteur BUFFALO 24 6 1 Qu est ce qu un moniteur 24 6 2 Cartographie m moire avec le moniteur BUFFALO 24 6 3 Commandes du moniteur BUFFALO 25 lied ui pn Gn RR 26 Oo 28 9 EX 0 Questions OCS 30 I0 EX 1 Analyse d un source ASM 68HC11 Comparaison avec l assembleur 68000 31 11 EX2 Echo sur la RS 232 Utilisation de la biblioth que LIBHCI1 32 12 EX 3 Echo sur la RS 232 Utilisation de la biblioth que d E S Cosmic 33 13 EX 4 Echo sur la RS 232 Ex cution directe du programme au reset en mode Eeer E EE EN 34 Ji PEO 71 pk enseirb 2004 v2 0 2 eu LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik AVANT PROPOS Ces Travaux Pratiques sont avant tout destin s atous ceux qui d sirent
79. ts de RAM Un timer 16 bits 3 entr es de capture 5 sorties de comparaison 2 accumulateurs 8 bits Une liaison s rie asynchrone SCI Une liaison s rie synchrone SPI Un convertisseur Analogique Num rique 8 bits 8 entr es multiplex es Circuit d interruption temps r el Circuit oscillant externe quartz 8 MHz dans notre application Le document donn en annexe 3 pr cise ce qu est un microcontr leur Apr s lecture de ce document vous devez tre capable de faire la diff rence entre un microcontr leur 68HC11 et un microprocesseur 68000 Les modes de fonctionnement du 68HC11 sont r sum s dans le tableau suivant voir annexe 5 Mode s lectionn La carte m re ENSEIRB r alis e permet l utilisation du microcontr leur 65HC11 dans tous les modes gr ce la pr sence de 2 interrupteurs MODA et MODB qui fixent la valeur de MODA et MODB vus pr c demment e Sch ma lectrique de la carte m re Le sch ma lectrique de la carte m re est donn ci apr s pk enseirb 2004 v2 0 6 Xie SRE mac LE MICROCONTROLEUR 8 BITS 68HC11 Patrice Kadionik J L vec PORT E PORT A IN OUT vee vec wo woo YE wel YE bw E lu dt lu blu d tu t S TELET x RS 232 SUB DES Figure 2 Sch ma lectrique de la carte m re 51 le microcontr leur travaille en mode tendu l util
80. x i 5H RTS Level 0 State STOPPED Base HER restart User RST SHEE loads testio2 User SWI SHEE asm User KIRO SHEHA WM WM b W WM WM Figure 6 Logiciel PCBUG11 en cours d utilisation La zone sup rieure est la zone de dialogue o s affiche le r sultat des op rations lanc es par l utilisateur La zone centrale au milieu montre l tat des registres du 68HC11 et droite le type de processeur ainsi que le mode de fonctionnement de PCBUGI1 Running Stopped Trace La partie inf rieure est r serv e l utilisateur pour rentrer les commandes de PCBUGI I Voici une br ve description des commandes essentielles de PCBUGI1 voir annexe 6 ASM addr permet le d sassemblage assemblage en ligne du code en m moire l adresse addr addrl addr2 bytelword permet de remplir un bloc de m moire commen ant addrl et terminant par addr2 avec la valeur byte word BR addr macroname cette fonction permet de placer des points d arr t autorisant ainsi l utilisateur de d bugger son programme en pas pas Cette fonction est utilisable seulement si l on a r pondu No la question Do you wish use the XIRQ interrupt au lancement de PCBUGII Le programme doit tre galement implant dans une zone de m moire accessible en criture puisque PCBUGII place une instruction SWI interruption logicielle l adresse du point d arr t d calant ainsi tout le reste
Download Pdf Manuals
Related Search
Related Contents
Versata Logic Suite Library Perception sélective de l`OFSP - Bulletin des médecins suisses Télécharger ハイブリッドアクチュエータ ユニット - 油圧ユニット 設計 製作「株式会社 MANUAL DE INSTRUCCIONES. SISTEMA STS RUSKA 2485-930 Biacore T200(Ver.1) 取扱説明書 基本操作編 Copyright © All rights reserved.
Failed to retrieve file