160 likes | 170 Views
Explore the advantages and considerations of using FIFO and double buffering for flow control protocols and data management in embedded systems. Learn about the benefits of modularizing applications using hierarchical states and virtual devices.
E N D
Topics • Business Matters • Read Simon Chapter 4 • Design Meeting • Some thought RAM might be easier than added SW Complexity … good point. Is it true? • Flow Control Protocol • Buffering: FIFO v. Double Buffering • Lab 2 • Play test sequence from ROM • Convert your own song (download from web) • http://www.knightvision.com/midis.html. • Play stream from workstation (Adam’s program)
Wednesday’s Quiz • Basic Electronics • Our music format • Interfacing devices to 8051 • Memory Mapped Design • 8051 Ass’y and interrupts • Resource Utilization
Example Buffering FIFO Or double buffer? Read Write
FIFO Case • ISR • If (not empty) get item, move “tail” pointerelse what? • Main • If (not full) put item, move “head” pointerelse what? • When writing this code: • Assume ISR and MAIN are parallel processing running on separate computers using shared memory to communicate: why?
FIFO • Empty Condition • Tail = Head • Tail is place to get next byte if != head • Initial Condition • Same as empty condition • Full Condition • Head = (Tail –1) • Head is place to put next byte if not right behind tail • Is there a bad time to get an interrupt?
Example • Queue size is 10 • In Main if (next(head) != tail) { queue[head] = data; head = next(head); } unsigned char next(unsigned char) { head = head + 1 if (head) > 9 head = 0; } • Do we have a problem? • Solution?
Double Buffering Case • When to switch buffers? • When write buffer is empty and read buffer is full? • What is the critical requirement for double buffering? • Why is it fine for video?
Midi conversion Input Resolution @120bpm = 2 qn/sec * 384u/qn = 768u/sec = 1.3ms/unit. Output resolution is: 20ms/ts /1.3ms/u = 15.36 u/timeslice To convert from input abs time to output abs time: divide by 15.36 and round off
Midi conversion: Time signature ¾ time signature means: 3 quarter notes/beat?? If so: compute time to first event: Compute time to second event: Third event:
Tracks and Channels mididmp time.mid > time.txt Encoding for First event? Second Event? Thirst Event? Fourth Event?
mid2cse: .txt to .466 mid2cse time.txt 7 120 20 –2 time.466 | less
The .466 File ff000000f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f8019801ff201d0c9801cf000000ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff201d0cf8016801ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff201d0cf8016801ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff201d0cf8016801ff0c201df801f8013801ff0000009801ff0c201df801f8013801ff00000030016914fe0c20f801f8013801ff000000f82
Embedded Software • Software States v. Finite State Machines • Hierarchical State • Thread/Process Communication • Critical Sections • Synchronization • Messaging and Signaling
Benefits • Modularization of the Application • Some Virtual Machine Features • Device Drivers (Virtual Devices)