| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
AN1752 Data Structures 8-Bit Microcontrollers Freescale Semi
Top Searches for this datasheetOrder this document AN1752/D AN1752 Data Structures 8-Bit Microcontrollers Freescale Semiconductor, Inc. Brad Bierschenk Consumer Systems Group Applications Engineering Austin, Texas Introduction data structure describes information organized stored computer system. Although data structures usually presented context large computers, same principles applied embedded 8-bit processors. efficient appropriate data structures improve both dynamic (time-based) static (storage-based) performance microcontroller software. This application note presents data structures which useful development microcontroller software. applications presented here means absolute. find infinite variety ways apply these basic data structures microcontroller application. Strings string sequence elements accessed sequential order. string data structure usually refers sequence characters. example, message which output display stored string ASCII character bytes memory. Motorola, Inc., 1998, 2001 AN1752 More Information This Product, www.freescale.com Application Note Storing Strings string elements must identified starting ending address. starting address string defined using absolute address label using base address group strings identifying particular strings with offset into group. There several methods terminating string information. common terminating string using special character mark string. terminating character value $04, ASCII (end-of-transmission) byte. Freescale Semiconductor, Inc. Figure shows example string data. DATA MESSAGE POINTER ADDRESS Figure String Data Structure Another method terminating string identify length. length then used counter value, eliminating need extra byte storage string. string ASCII characters terminated without using extra byte storage using sign (most significant bit) indicator last byte string. Because ASCII character data only seven bits long, last byte string indicated most significant location. When using this method, programmer must careful strip sign before using ASCII character value. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Strings Accessing Strings efficient accessing string with indexed addressing mode INCX DECX instruction. Listing String Storage Example Listing String Access Example illustrate this string storage scheme Listing String Storage Example Absolute string addresses specifying string data *-Message1 'This string' Message2 'This another string' Indexed string addressing Another specifying string data *-Msgs Message3 *-Msgs 'This string' Message4 *-Msgs 'This another string' Freescale Semiconductor, Inc. Listing String Access Example String display code generic method displaying entire string. *-LoadMsg #Message1 ;Offset into Loop Messages,X ;Load character #$04 ;Check StringDone ;End string ShowByte ;Show character INCX ;Point next Loop String storage code *-Messages Message1 *-Messages 'This string' AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note String Applications Practical applications strings include storing predefined "canned" messages. This useful applications which require output text displays, giving users information prompting users input. Strings also effective storing initialization strings hardware such modems. Strings also store predefined command data sequences communicate with other devices. Stacks Freescale Semiconductor, Inc. stack series data elements which accessed only end. analogy this data structure stack dinner plates; first plate placed stack last plate taken from stack. this reason, stack considered LIFO (last first out) structure. stack useful when latest data desired. stack will typically have predefined maximum size. shows representation stack. DATA EMPTY EMPTY STACK POINTER EMPTY DATA BYTE DATA BYTE DATA BYTE DATA BYTE DATA BYTE ADDRESS STACK BOTTOM STACK GROWS THIS DIRECTION STACK (MAXIMUM) Figure Stack Data Structure AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Stacks Just like physical stack items, software stack bottom top. Software should keep track location stack. This address either point first piece valid data point next available location. following examples will pointing next available location. Stack Reading Writing Freescale Semiconductor, Inc. read operation stack called "pulling" "popping"), write operation stack called "pushing." When pulls data from stack, data removed from stack stack pointer adjusted. When data pushed onto stack, stack pointer adjusted data added stack. implementation Figure push operation would first decrement stack pointer then store data address pointed (stack pointer) pull operation would retrieve data (stack pointer) then increment stack pointer. error conditions intrinsic this data structure; underflow overflow. stack underflow occurs when user attempts pull information empty stack. stack overflow occurs when user attempts push information onto stack which full. When using this data structure, these conditions should attended underflow condition should return error. overflow, either reject data return error, stack "wrap" around bottom, destroying data bottom stack. Hardware Stack Motorola MCUs utilize stack structure saving program context before transferring program control. This interaction result jump interrupt. result interrupt, stack used push values (condition code register) registers, well 16-bit (program counter) value. When jump instruction encountered, value pushed stack. returning from interrupt (RTI instruction) program context (registers pulled from stack. When returning from jump (RTS instruction) pulled from stack. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note HC05 Stack HC05 Family MCUs have limited stack access. only operation that performed with MCU's stack pointer reset instruction will reset stack pointer $FF. HC05 stack pointer also limited size bytes. When stack pointer grows beyond address $C0, stack pointer wraps around $FF, destroying existing data that address. HC08 Stack Freescale Semiconductor, Inc. HC08 Family MCUs more flexible stack structure. stack pointer address. HC08 MCUs also have added addressing mode which indexed stack pointer. this way, user pass parameters subroutines using hardware stack, accessing parameters using stack pointer indexed addressing. Other HC08 Family instructions allow data pushed pulled stack. stack pointer also transferred index register vice-versa. With addition these instructions addressing modes, user good control over stack HC08 MCU. Stack Applications stack useful dynamically allocating memory passing parameters from subroutines. Typically, variables statically allocated assembly time. example: Statically allocated variables RAMSPACE Another method statically allocate variable RAMSPACE+4 RAMSPACE+5 MyVar1 MyVar2 MyVar3 MyVar4 MyVar5 This appropriate global variables, which need available throughout program flow. However, local variables which only used specific subroutines, this method most efficient. space these variables dynamically allocated using software stack stack, freeing memory. same AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Stacks method applied subroutine input output parameters, passing them stack instead register. Listing Software Stack shows software implementation stack, which would appropriate HC05 Family microcontrollers. Freescale Semiconductor, Inc. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Listing Software Stack STACK.ASM simple software stack implementation Simply shows PUSH PULL operations stack; intended complete application. StackPtr points next (empty) available location Written MC68HC705P6A *-*-* Memory equates *-RAMSPACE ROMSPACE $100 RESETVEC $1FFE Stack equates *-STACKSIZE STACKBOT ;Bottom software stack STACKMAX {STACKBOT-STACKSIZE+1} ;Maximum address stack variables *-ORG RAMSPACE ;First address StackPtr ;Pointer next stack byte Start program code *-ORG ROMSPACE ;Start Init #STACKBOT ;Initialize stack pointer StackPtr Some simple read write operations illustration only *-LDA #$01 PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack FullErr PushA ;Write stack AN1752 MOTOROLA Freescale Semiconductor, Inc. More Information This Product, www.freescale.com Application Note Stacks Loop FullErr PushA FullErr PushA FullErr PullA EmptyErr PullA EmptyErr PullA EmptyErr ;Write FULL stack ;Write FULL stack ;Read from stack ;Read from stack ;Read from stack ;Your code here ;Your code here ;Your code here Freescale Semiconductor, Inc. EmptyErr FullErr Subroutines code access data structure *-*-* PUSH subroutine Push contents accumulator onto stack indicate full error *-PushA StackPtr ;Get stack pointer #STACKMAX ;Check full stack Full DECX ;Decrement stack pointer ;Store data StackPtr ;Record stack pointer ;Clear carry ;Return Full ;Set carry error ;Return PULL subroutine PULL byte stack into accumulator indicate empty stack error *-PullA StackPtr ;Get stack pointer #STACKBOT ;Check empty stack Empty ;Get data INCX ;Increment stack pointer StackPtr ;Record stack pointer ;Clear carry ;Return Empty ;Set carry ;Return Vector definitions *-ORG RESETVEC Init AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Using software stack, subroutine allocate variables pushing (allocating) bytes stack, accessing them with indexed addressing (relative stack pointer variable) pulling them (deallocating) before returning. this way, same space used multiple subroutines. Parameters passed from subroutines well. input parameter pushed stack. When subroutine entered, access input parameter relative stack pointer. same token, subroutine push output parameter onto stack passed back calling routine. hardware stack stack pointer also used these purposes. Because expanded instruction set, stack easily exploited HC08 Family microcontrollers. Listing Using HC08 Stack Operationsshows example using HC08 stack pass parameters allocate local variables. Freescale Semiconductor, Inc. Listing Using HC08 Stack Operations Using stack pass parameters allocate variables optimizes memory usage. Code segment example using HC08 stack pass parameters allocate local variables. intended complete application. *-LDA PSHA PSHA PULA PULA Loop #$AA ;Load some data passed ;Push parameter subroutine ;Push parameter subroutine ;Call subroutine ;Parameter passed back ;Parameter passed back Result1 ;Your code here Result2 AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Stacks Freescale Semiconductor, Inc. Subroutine which uses stack variable access SP->Empty LOCAL2 LOCAL1 PARAM2 PARAM1 -*-PARAM1 ;Parameters passed PARAM2 LOCAL1 ;Local variables LOCAL2 *-Sub PSHA ;Allocate local variable PSHA ;Allocate local variable ROLA ROLA PULA PULA PARAM1,SP LOCAL1,SP PARAM2,SP LOCAL2,SP LOCAL1,SP PARAM1,SP LOCAL2,SP PARAM2,SP ;Load parameter passed something ;Store local variable ;Load parameter passed ;Store local variable ;Store value passed back ;Store value passed back ;Deallocate local variable memory ;Deallocate local variable memory ;Return AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Queues queue series elements which accepts data from extracts data from other end. analogy this data structure would checkout line supermarket. first people first people out. this reason, considered FIFO (first first out) structure. This useful when accessing data order received. queue will usually have predefined maximum size. Freescale Semiconductor, Inc. Figure illustrates queue. DEQUEUE FROM 'GET' POINTER DATA DATA DATA DATA ENQUEUE 'PUT' POINTER DATA EMPTY EMPTY EMPTY QUEUE BOTTOM QUEUE GROWS THIS DIRECTION QUEUE DATA ADDRESS Figure Queue Reading Writing read operation queue called "dequeue," write operation "enqueue." pointers necessary queue, head line, tail. enqueue operation, after checking size queue, data stored location pointed "put" pointer, pointer adjusted. dequeue operation, data read from "get" pointer location, pointer adjusted. Queues usually have fixed size, important keep track number items queue. This done with variable containing size queue with pointer arithmetic. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Queues Queue Errors with stack structure, queue subject underflow overflow errors. write, "enqueue" operation, should nondestructive should error queue full. read, "dequeue" operation, should destructive (remove data element) should error queue empty. Queue Applications practical application FIFO queue data buffer. Queues used buffers transmitted received data with printers serial communication devices. Listing Queue Example shows example queue software. good application this would store data received from SIOP (serial input/output port) processing later. Freescale Semiconductor, Inc. Listing Queue Example Illustrates implementation queue 705P6A Register definitions Memory definitions RAMSPACE ROMSPACE RESETVEC $100 $1FFE Queue data structure definitions These three equates defines data structure change queue, change data structure, code. QMAX ;Maximum size QTOP ;Top array QBOT QTOP+QMAX-1 ;Bottom array variables TempA TempX RAMSPACE GetPtr PutPtr QCount ;8-bit pointer ;8-bit pointer ;Counter size AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Start program code *-ORG ROMSPACE Start InitQ #QTOP ;Initialize pointers variables GetPtr PutPtr QCount Write read from good application this place bytes received from into queue, retrieve them later *-JSR #$FF #$55 Loop Freescale Semiconductor, Inc. Subroutines *-*-* enqueues data byte passed accumulator Checks full returns carry full. Otherwise returns cleared carry successful enqueue. *-EnQ TempX Save register contents QCount ;Check full CMPX #QMAX QFull full error PutPtr ;Store data CMPX #QBOT ;Check wrap WrapPut ;Wrap pointer INCX ;Adjust pointer EnQDone WrapPut #QTOP ;Successful enqueue AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Queues ;Unsuccessful enqueue QFull EnQDone PutPtr TempX QCount ;Store pointer ;Restore register ;Increment count variable ;Clear carry ;Return ;Restore register ;Set carry ;Return TempX Freescale Semiconductor, Inc. Dequeue byte from queue, return byte accumulator queue empty, return carry indicate error. Otherwise, return clear carry data *-DeQ TempX ;Save register contents QCount ;Check empty CMPX #$00 QEmpty GetPtr CMPX #QBOT ;Check wrap condition WrapGet INCX DeQDone WrapGet #QTOP ;Successful dequeue DeQDone GetPtr ;Record pointer TempX ;Restore register QCount ;Decrement counter ;Clear carry ;Return ;Unsuccessful dequeue QEmpty TempX ;Restore register ;Set carry ;Return Vector definitions *-ORG RESETVEC Start AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note MACQ (Multiple Access Circular Queue) multiple access circular queue circular buffer) modified version queue data structure. fixed-length, order-preserving data structure, always contains most recent entries. useful data flow problems, when only latest data interest. Once initialized always full, write operation always discards oldest data. Freescale Semiconductor, Inc. Figure depicts MACQ. Reading Writing After being initially filled, write operation will place data MACQ, shift existing data downward. last byte will discarded, result latest data existing buffer. read operation non-destructive return number data bytes desired from MACQ. LATEST DATA HERE DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA ADDRESS OLDEST DATA DISCARDED Figure Result MACQ Write AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note MACQ (Multiple Access Circular Queue) Applications MACQ useful data streams which require latest data afford have destructive write operation. example, predict weather forecaster might temperature readings from last five days predict next day's temperature. Daily temperature readings recorded MACQ, latest data available. MACQs also useful digital filters. example, they used calculate second derivative, running average, etc. Freescale Semiconductor, Inc. Example Listing MACQ illustrates implementation MACQ circular buffer. This could effectively used storing converter readings. this way, latest conversion results would accessible through circular buffer. Listing MACQ Illustrates implementation multiple-access circular queue. (MACQ) MACQ fixed-length, order-preserving, indexable data structure. Once initialized, MACQ always full. write MACQ destructive, discarding oldest data. read from MACQ non-destructive. 705P6A Register definitions Memory definitions RAMSPACE ROMSPACE RESETVEC $100 $1FFE MACQueue data structure definitions These three equates defines data structure change queue, change data structure,and code. QSIZE ;Maximum size QTOP ;Top array QBOT QTOP+QSIZE-1 ;Bottom array variables TempA TempX TempData QPtr RAMSPACE ;8-bit pointer AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Start program code *-ORG ROMSPACE Start InitQ #QBOT ;Initialize pointer QPtr Write read from MACQ useful application this would store converter readings, latest readings available. *-LDA #$55 WriteQ #$56 WriteQ #$57 WriteQ #$58 WriteQ #$AA WriteQ #$AB WriteQ #$AC WriteQ #$AD WriteQ WriteQ ReadQ ReadQ ReadQ Loop Freescale Semiconductor, Inc. Subroutines *-*-* WriteQ, contains data written write destructive full once initialized always full. *-WriteQ TempX ;Store register value QPtr ;Load pointer CMPX #QTOP-1 ;See full QFull ;Store data AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Tables QPtr WQDone ;Decrement pointer ;Store pointer Freescale Semiconductor, Inc. Once MACQ initialized, it's always full QFull TempData QBOT-1 SwapLoop DECX CMPX #QTOP SwapLoop #QTOP TempData WQDone TempX ;Start shifting data down ReadQ contains queue index location read returns value *-ReadQ TempX #QTOP (index) QTOP pointer address desired value Vector definitions *-ORG RESETVEC Start Tables table viewed vector identically structured lists. table common storing "lookup" data, such display data vector bytes. Figure shows example table. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note TOP-OF-TABLE POINTER DATA $0100 $0500 $0800 $0090 $1200 $2200 ADDRESS Freescale Semiconductor, Inc. $0100 $0100 Figure Table Representation table commonly used look information. Table entries accessed with offset from base address table. Therefore, read from table typically done computing offset desired data accessing using indexed addressing mode. Table Applications table data structure common applications. using tables perform character conversions. example, table used convert binary numbers equivalents. (liquid crystal display) displays, ASCII character byte need converted segment bitmaps display. table could used this purpose. Another application table "jump" table. This table vector values which addresses loaded vectored Some program parameter converted offset into jump table, appropriate vector fetched certain input. example, their memory maps Motorola MCUs have built-in vector table, used interrupt exception processing. These vector tables allow preprogrammed addresses defined certain exceptions. When exception occurs, program counter value fetched from appropriate table entry. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Tables Another utilizing table data structure store predefined values lookup. example this storing interpolation data table, perform mathematical functions. This table documented application note, M68HC08 Integer Math Routines, Motorola document order number AN1219. Another example involves using table sinusoidal values produce sine wave output application note Arithmetic Waveform Synthesis with HC05/08 MCUs, Motorola document order number AN1222. equation calculate data CPU-intensive approximated with discrete values, these values precalculated stored table. this way, value quickly fetched, saving time. Freescale Semiconductor, Inc. Table Example Listing Table example tables convert ASCII data segment values. Listing Table Code segment example using table store segment values Could used when data registers define segment values display position. Takes ASCII character, converts offset into table segment values, uses offset access segment bitmap values. *-Loop Character ;Load ASCII character Convert ;Convert character ;Offset into table ;Load first byte LCD1 ;Store data register ;Load second byte LCD2 ;Store data register Loop ;Repeat Convert ASCII character byte offset value into table segment values. Valid ASCII values (decimal): 32-47, 48-57, 65-90 *-Convert #!48 ;Check "special" character Special #!65 ;Check numeric character Numeric Alpha #!90 ;Check invalid value ConvError AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note CLRA ROLA #!39 ConvDone #!32 ConvError #!32 ConvDone #!57 ConvError #!32 ConvDone ;Convert table offset ;Check invalid value ;Convert table offset ;Check invalid value ;Convert table offset ;Invalid value shows blank ;Multiply offset bytes data position Special Numeric ConvError ConvDone Freescale Semiconductor, Inc. Lookup table segment values ASCII character values Some characters displayed 15-segment LCD, they marked invalid, will displayed blank space. *-Table $0000 $0000 ;'!' INVALID $0201 ;'"' $0000 ;'#' INVALID $A5A5 ;'$' $0000 ;'%' INVALID $0000 ;'&' INVALID $0001 ;''' $000A ;'(' $5000 ;')' $F00F ;'*' $A005 ;'+' $0000 ;',' INVALID $2004 ;'-' $0800 ;'.' $4002 ;'/' $47E2 ;'0' $0602 ;'1' $23C4 ;'2' $2784 ;'3' $2624 ;'4' $21A8 ;'5' $25E4 ;'6' $0700 ;'7' $27E4 ;'8' $27A4 ;'9' $2764 ;'A' $8785 ;'B' $01E0 ;'C' $8781 ;'D' $21E4 ;'E' $2164 ;'F' AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Linked Lists Freescale Semiconductor, Inc. EndTable $05E4 $2664 $8181 $06C0 $206A $00E0 $1662 $1668 $07E0 $2364 $07E8 $236C $25A4 $8101 $06E0 $4062 $4668 $500A $9002 $4182 *-Table ;'G' ;'H' ;'I' ;'J' ;'K' ;'L' ;'M' ;'N' ;'O' ;'P' ;'Q' ;'R' ;'S' ;'T' ;'U' ;'V' ;'W' ;'X' ;'Y' ;'Z' ;End table label Linked Lists list data structure whose elements vary precision. example, record containing person's name, address, phone number could considered list. linked list group lists, each which contains pointer another list. Figure represents linked list. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note NEXTPTRA NEXTPTRB NEXTPTRC DATA1A DATA2A DATA3A DATA4A DATA1B DATA2B DATA3B DATA4B LISTB DATA1C DATA2C DATA3C DATA4C LISTC Freescale Semiconductor, Inc. LISTA Figure Linked List Each list structure contains same type information, including link next item list. link might absolute address offset from some base address. doubly linked list, pointers kept both next previous item list. linked list traversed easily simply following pointers from list next. Linked List Applications linked list used traditionally define dynamically allocated database, which elements ordered resorted adjusting links. However, small microcontroller, there more appropriate applications linked lists. linked list used structure command interpreter. Each command could contain string characters, address subroutine call that command, link next command linked list. this way, command string could input, searched linked list, appropriate action taken when string found. State Machines Another useful application linked list define state machine. state machine represented discrete number states, each which output pointers next state(s). Figure AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Linked Lists STATE STATE Freescale Semiconductor, Inc. STATE INPUT/OUTPUT STATE Figure State Machine state machine considered Mealy Moore machine. Mealy machine's output function both inputs current state. Moore machine output dependent only current state. This state machine model useful controlling sequential devices such vending machines, stepper motors, robotics. These machines have current internal state, receive input, produce output, advance next state. first model process sequential machine, then convert this behavior linked-list structure write interpreter important goal able make modifications state machine changing data structure (linked list) code. State Machine Example example, consider traffic light controller which determines light patterns intersection. light patterns needed, north/south directions east/west directions. Consider that bulk traffic travels north/south road, sensors placed east/west road intersection determine when traffic needs cross. Figure AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note INPUT INPUT Freescale Semiconductor, Inc. Figure Traffic Light Controller Example This example modeled Moore state machine, with output function current state. next state function current state state input. Figure shows state graph this example. initial state will green light north/south direction light east/west direction. controller remains this state, until input seen east/west direction. flow continues shown diagram. output shown diagram pattern light array activate lights state. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Linked Lists INPUT OUTPUT 11011110 DELAY INPUT OUTPUT 11011101 DELAY INPUT INPUT Freescale Semiconductor, Inc. OUTPUT 11110101 DELAY INPUT OUTPUT 11110011 DELAY Figure Traffic-Light Controller State Graph Simulation This example simulated using LEDs 68HC705P6A MCU. pushbutton switch used simulate input sensor. Figure illustrates simulation circuit. Using bits output port, pattern generated display appropriate north/south east/west lights (LEDs). Table shows bitmap this application. AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note OUTPUTS 74LS04 705P6A OUTPUTS 74LS04 Freescale Semiconductor, Inc. INPUT Figure Circuit Simulation Traffic-Light Controller Table Traffic Light Bitmap Port Position Meaning used North/South Signal East/West Signal With hardware place, that left define state machine software. This done implementing linked-list data structure code access interpret machine. this particular example, each list data structure defines current state traffic light. Each list contains: byte which bitmap lights. delay value; time controller remains state next state pointer input next state pointer input AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Linked Lists main loop program should execute program flow charted Figure software this simulated traffic light controller documented Listing Traffic Controller State Machine. LOAD INITIAL STATE Freescale Semiconductor, Inc. OUTPUT LIGHT PATTERN LOAD NEXT STATE POINTER (OFFSET) DELAY GIVEN VALUE LOAD NEXT STATE POINTER (OFFSET) INPUT INPUT INPUT Figure State Machine Program Flow Listing Traffic Controller State Machine Traffic light controller example Illustrates linked list implementation state machine 705P6A Register definitions PORTA PORTD DDRA DDRD Memory definitions RAMSPACE ROMSPACE RESETVEC variables $100 $1FFE RAMSPACE AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note TempA TempX Start program code *-ORG ROMSPACE Start #$00 PORTA ;Predefine output levels #$FF DDRA ;Make Port outputs BCLR 7,PORTD ;Make Port input Freescale Semiconductor, Inc. Loop BRCLR #INITST STATES+LIGHTS,X PORTA STATES+DELAY,X SecDelay 7,PORTD,In0 STATES+NEXT0,X Loop STATES+NEXT1,X Loop ;Index initial state ;Get light pattern ;Output light pattern ;Get delay seconds ;Cause delay ;Check input ;Get next state offset ;(input ;Get next state offset ;(input DATA STRUCTURE STATE MACHINE LINKED LIST (05) Offsets base address scheme adequate small table (<255 bytes) *-LIGHTS ;Offset light pattern DELAY ;Offset time delay NEXT0 ;Offset pointer NEXT1 ;Offset pointer STATES ;Base address states INITST *-STATES ;Initial state offset North/South green light, East/West light *-STATES ;Offset into STATES %11011110 ;Output state ;Delay state ;Next state input ;Next state input yellow light, light *-STATES %11101110 light, green light *-STATES %11110011 ;Delay state AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Linked Lists yellow light, light *-STATES %11110101 ;Delay state Freescale Semiconductor, Inc. Delay subroutines Cause delay second Accumulator value) 1MHz *-SecDelay #$00 SecDone Delay0 Delay0 DECA SecDelay SecDone Cause delay ~1/2 second *-Delay0 TempX #$B2 DLoop0 CMPX #$00 DDone0 Delay1 DECX DLoop0 DDone0 TempX Cause about 2.8msec delay 1MHz *-Delay1 TempA #$FF DLoop1 #$00 DDone1 DECA DLoop1 DDone1 TempA Vector definitions *-ORG RESETVEC Start AN1752 MOTOROLA More Information This Product, www.freescale.com Application Note Conclusion data structures necessarily limited large, complicated computers. Although data structure powerful concept such context, same principles applied smaller processors such 8-bit microcontrollers. code implement these data structures does necessarily have complex confusing. goal programming should modularize commonly used functions, that they reused other applications with minimal amount modification. appropriate data structure concepts improve static dynamic performance application, without affecting portability legibility. Freescale Semiconductor, Inc. Motorola reserves right make changes without further notice products herein. Motorola makes warranty, representation guarantee regarding suitability products particular purpose, does Motorola assume liability arising application product circuit, specifically disclaims liability, including without limitation consequential incidental damages. "Typical" parameters which provided Motorola data sheets and/or specifications vary different applications actual performance vary over time. operating parameters, including "Typicals" must validated each customer application customer's technical experts. Motorola does convey license under patent rights rights others. Motorola products designed, intended, authorized components systems intended surgical implant into body, other applications intended support sustain life, other application which failure Motorola product could create situation where personal injury death occur. Should Buyer purchase Motorola products such unintended unauthorized application, Buyer shall indemnify hold Motorola officers, employees, subsidiaries, affiliates, distributors harmless against claims, costs, damages, expenses, reasonable attorney fees arising directly indirectly, claim personal injury death associated with such unintended unauthorized use, even such claim alleges that Motorola negligent regarding design manufacture part. Motorola registered trademarks Motorola, Inc. Motorola, Inc. Equal Opportunity/Affirmative Action Employer. reach USA/EUROPE/Locations Listed: Motorola Literature Distribution; P.O. 5405, Denver, Colorado 80217. 1-303-675-2140 1-800-441-2447 JAPAN: Motorola Japan Ltd.; SPS, Technical Information Center, 3-20-1, Minami-Azabu, Minato-ku, Tokyo 106-8573 Japan. 81-3-3440-3569 ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd.; Silicon Harbour Centre, King Street, Industrial Estate, N.T., Hong Kong. 852-26668334 Technical Information Center: 1-800-521-6274 HOME PAGE: Motorola, Inc., 1998, 2001 AN1752/D More Information This Product, www.freescale.com Other recent searchesTPA4860 - TPA4860 TPA4860 Datasheet T8208 - T8208 T8208 Datasheet M56753FP - M56753FP M56753FP Datasheet IDT54 - IDT54 IDT54 Datasheet 74FCT16374T - 74FCT16374T 74FCT16374T Datasheet IDT54 - IDT54 IDT54 Datasheet 74FCT162374T - 74FCT162374T 74FCT162374T Datasheet HMC535LP4 - HMC535LP4 HMC535LP4 Datasheet GBU4A - GBU4A GBU4A Datasheet GBU4M - GBU4M GBU4M Datasheet C01E - C01E C01E Datasheet AT42QT1110 - AT42QT1110 AT42QT1110 Datasheet
Privacy Policy | Disclaimer |