![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
m68hc08 microcontrollers freescale.com mc68hc908qy4 lin backlit keypad slave designer reference manual DRM058/d rev. 1 07/2007
mc68hc908qy4 lin backlit keypad slave designer reference manual DRM058/d rev. 1 07/2004 by: matt ruff 8/16 bit systems engineering austin, texas revision history rev. section description of change 0 throughout initial release 1 section 4; throughout changed headings in table 4-1; changed to freescale format mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 5 table of contents chapter 1. system overview 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 1.3 basic system operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 chapter 2. lin messaging 2.1 lin message frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 2.2 scheduling tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 chapter 3. backlit keypad hardware 3.1 mc68hc908qy4 backlit lin slave keypad unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1.1 button interfacing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.1.2 led backlighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.3 connectors and harnesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 chapter 4. keypad slave software 4.1 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 4.2 codewarrior? project and file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 4.3 application code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 4.3.1 application software state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.3.2 state description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.3.3 application data storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.3.4 choosing adc trip points for buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 4.3.5 software switch debouncing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.4 lin software drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.4.1 changes from lin drivers in an2599/d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.4.2 configuring messaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.5 performance issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.5.1 lin driver isr vs. timch0 flag polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 chapter 5. lin master module emulation using the lin spector 5.1 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 6 freescale semiconductor chapter 6. design enhancements and upgrades 6.1 overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 6.2 software performance improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 6.3 software functionality upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 6.4 hardware improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 6.5 hardware functional upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 chapter 7. references and acknowledgements 7.1 references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 7.2 acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 9 appendix a. lin_qy_backlight_keypad_messaging_strategy_1_0.ldf . . . . . . . . . . . . . . .51 appendix b. led_sweep.lec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 appendix c. schematic and bom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 7 chapter 1. system overview 1.1 introduction this manual describes a reference design for a local interconnect network (lin) enabled steering wheel keypad module with light emitting diode (led) backlighting. the design is based on the mc68hc908qy4 microcontroller and mc33689 lin system basis chip (sbc). by placing the keypad on a lin network, the designer is able to reduce the wiring required through the expensive clocksp ring wiring connection in the steering wheel and add any number of new features to the steering wheel without having to change this expensive connector. this design shows one way that a basic keypad unit can be placed onto the lin network with simple components. the design also serves as a base design which can be added to or increased in complexity without additional connections through the clockspring. the entire system consists of the keypad module (which is a slave on a lin network), a satellite board (which contains more buttons and backlighting leds for the right side of the steering wheel), and a lin master node. for this reference design, the lin master node uses standard lin tools to control and monitor the keypad unit. design of the master module and satellite keypad is beyond the scope of this design, but the messaging used by the master to monitor switches and control backlighting levels is included. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 8 freescale semiconductor system overview 1.2 features this reference design features: monitoring of 13 buttons for cruise control, hvac (heating, ventilation, and air conditioning), and radio controls on an automotive steering wheel lin connectivity using lin 1.3 standard messaging autobauding to any lin bus speed from 1 kbps to 20 kbps led backlighting with 16 network-controlled brightness levels using pwm (pulse-width modulation) 3-wire connection to clockspri ng? independent of button count (lin, v bat , ground) lin communications and pwm backlighting achieved using single timer module based on low-cost 16-pin mc68hc908qy4 microcontroller lin is a low-cost serial data bus standard, based on universal asynchronous receiver transmitter (uart) hardware. lin is targeted at low cost, low data rate networks, enabling the connection of motors, sensors, and actuators. vehicle hvac systems and electric power seats are good examples of systems in wh ich lin is used. these example systems contain multiple motors, sensors, and control panels which can easily be controlled through a relatively low-speed network (lower than 20 kbps) without impeding system performance. networking these components rather than the traditional point-to-point wiring eliminates a large amount of wiring, reduces potential points of failure at wiring connections, and allows for the use of more advanced diagnostics. a lin network in the steering column might include slave nodes for a switch panel (keypad) on the steering wheel, a switch monitor in the turn signal stalk, and/or an ignition switch node. the wiring reduction in the steering column can be substantial, because many switches currently require two wires per switch to run from the switch through the steering column to a central control box. some multiplexing of switches can be done using resistor divider networks, but this only works for a limited number of switches before requiring the use of more precise and expensive resistors. system overview features mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 9 figure 1-1 shows a typical steering column wiring with a few extra features. in this example, at least 17 wires are required to enable these features in the steering column. depending upon the complexity of functions and switches in the turn si gnal stalk, the number of wires could easily be larger. figure 1-1. typical (non-lin) steering column wiring diagram figure 1-2 shows how using a lin network in the steering column can eliminate 14 or more wires in this steering column, which can reduce the size and conductor count of the connectors at every node. additionally, connectors at each node can now be made virtually identical, decreasing cost through volume purchasing and increased manufacturability. turn signal stalk: turn signal stalk: interval wiper interval wiper (1) (1) washer pump washer pump (1) (1) headlight dim headlight dim (1) (1) ground ground (1) (1) new features (+) control box heat cool cool steering column steering column ignition switch : ignition switch : key switch key switch (3) (3) immobilizer immobilizer (1) (1) keyhole lighting keyhole lighting (1) (1) ground ground (1) (1) column extension column extension adjust motor adjust motor clockspring clockspring conn conn : : keypad keypad (4) (4) heat heat (1) (1) cool cool (1) (1) ground ground (1) (1) mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 10 freescale semiconductor system overview figure 1-2. steering column lin network in the clockspring mechanism, conductor count and connector standardization are important concer ns. the clockspring links the wiring in the column to the devices in the steering wheel, which must rotate through a large range of motion and maintain electrical contact. the wheel might contain such diverse applications as keypads, airbag, heating and cooling circuitry, and lighting. clocksprings are relatively expensive components and increase in cost with increasing numbers of conductors. in a traditional system, such as shown in figure 1-1 , as many as seven conductors are requir ed to support the keypad, heating, and cooling functions alone. to add these functions to a traditional system that was not originally designed with them, the manufacturer must absorb the cost of the bigger clockspring, increase the cost of the assembly, or stock multiple clocksp rings to accommodate all levels of vehicle options. in a lin system, however, only three conductors and a single clockspring with a standard sing le connector are required for any level of functions. turn signal stalk: turn signal stalk: interval wiper interval wiper ( ( - - ) ) washer pump washer pump ( ( - - ) ) headlight dim headlight dim ( ( - - ) ) ground ground ( ( - - ) ) new features ( ( - - ) ) column extension column extension adjust motor adjust motor control box (lin master) (lin master) steering column steering column ignition switch : ignition switch : key switch key switch ( ( - - ) ) immobilizer immobilizer ( ( - - ) ) keyhole lighting keyhole lighting ( ( - - ) ) ground ground ( ( - - ) ) heat cool cool system overview features mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 11 conversion to lin not only allows for cost reduction while maintaining the same level of functionality, it allows for dramatically increased design flexibility in the steering wheel applications without adding any new wiring. if the designer is able to add features without adding wires through the clockspring, features such as adaptive backlighting, driver grip pressure sensing, or even fingerprint recognition can be added or removed from a vehicle for only the cost of the application itself. some of these features are discussed in chapter 6. design enhancements and upgrades . figure 1-3 shows a basic overview of a lin enabled steering wheel keypad and how it connects to the master node of the system. figure 1-3. reference design system overview satellite satellite keypad keypad clockspring clockspring mechanism mechanism lin master node hc908qy4 hc908qy4 lin backlit lin backlit keypad keypad mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 12 freescale semiconductor system overview much more elaborate features can be implemented, but the two basic functions are monitoring a set of switches and illuminating those switches with leds. some additional features and enhancements to this basic design are described in chapter 6. design enhancements and upgrades . figure 1-4 is a block diagram of the keypad that shows the basic components and interconnections. one of the other key features of this design is that it uses the very small and inexpensive mc68hc908qy4 microcontroller unit (mcu) to operate the lin communications, pwm backlighting, and switch monitoring. this is accomplished with only a single two-channel timer module and general-purpose input and output pins. much of the other circuitry required in such a design, such as voltage regulation from automotive battery voltage (v bat ) down to 5 v, lin physical interfacing, and v bat level led drive are accomplished with the use of the mc33689 lin system basis chip (sbc). the lin sbc also extends the input and output capabilities of the 16-pin package of the mcu to allow the addition of more switches or output devices. figure 1-4. keypad block diagram hc908qy4 lin backlit keypad satellite keypad 4 hc908qy4 mcu tx rx spi set set res res cst cst off off on on pwm led output vdd vol+ vol+ vol vol - - mem mem mode mode fan fan - - fan+ fan+ tmp+ tmp+ tmp tmp - - vdd atd tim vdd lin vbat gnd lin mate node module clockpi clockpi mecai mecai steei colu steei colu mc89 lin syte bai cip system overview basic system operation mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 13 figure 1-5. mc68hc908qy4 backlit lin keypad with satellite keypad and harness 1.3 basic system operation the core components of the system are the lin backlit keypad module and the lin master module. this reference design focuses primarily on the design of the keypad unit, which is a slave on the lin network. the functions of the master node are emulated using a standard lin development tool called the lin spector ? from volcano automotive group and are described in more detail in chapter 5. lin master module emulation using the lin spector . in a lin network, the master node initiates all communications on the network. in this system, it simply po lls the keypad for button status using request messages and transmits led lighting levels via command messages. the keypad constantly checks the switches for status, updates the pwm output for the leds based on the current backlighting level, and responds to any recognized lin message header that arrives. lin messaging details are explained in chapter 2. lin messaging . lin spector ? is a trademark of volcano automotive group. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 14 freescale semiconductor system overview mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 15 chapter 2. lin messaging the keypad is designed to respond to four lin messages; three are for status and control and one is the lin standard sleep message. the three specific status and control messages can be modified easily in linmsg.c ; however, adding messages may affect code performance. refer to 4.5 performance issues for more detail. 2.1 lin message frames the following lin message frames are used: full details of the messaging can be found in the lin description file (ldf) found in the reference design software download file and in appendix a. lin_qy_backlight_keypad_messaging_strategy_1_0.ldf . the format for this file is part of the lin standard, which means that the ldf file describes the lin messaging in a standard way so that it will work with all lin compliant tools. table 2-1. lin message frames lin id (with parity) frame name frame description byte 0 byte 1 0xca lin_stat j2602 and lin 2.0 compliant status byte application status, lin communication status ? 0x8b key_status keypad button press status cruise control button status hvac and radio button status 0x4c int_light_cmd interior lighting command message backlighting on/off and level data ? 0x80 ? lin 1.0 system sleep message ? ? 0x3c ? lin 1.3+ system sleep message (not currently supported) 0x00 ? mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 16 freescale semiconductor lin messaging the lin_stat message is not used in this reference design, but it is included to show how this lin and saej2602 standard status byte might be used in a system. the slave supplies to the master a 1-byte status update that contains lin bus error conditions and application status information. this allows the master to rapidly poll the slave node status by requesting a 1-byte message without having to ask for detailed status data, which requires longer messages. the lin driver in this reference design does track bit errors and checksum errors, however they are not currently reported in the lin_stat message. the application status information in bits 0 through 4 are defined by the application designer. the only reserved value is 0x00, which indicates that there is no data to report. the application status field is updated in the reference design (as an example) whenever a button is pressed. the encoding of the lin_stat message byte allows the master node to rapidly request this 1-byte status update and monitor the most significant bit (msb) for lin bus error conditions and the least significant bit (lsb) for application state changes. the key_status and int_light_cmd messages are the primary messages used in this reference design. because only 13 bits are required to report button status (with one additional bit that reports the pressing of any button), only a 2-byte status response is required in message key_status . the added latency (2 bytes instead of 1 byte) is minimal. therefore in this reference design, the master simply uses this message to monitor the condition of the keys. the key_state_chg signal (bit 7 of byte 0) serves the same function as the lsb of the lin_stat message. the int_light_cmd is a command message the master node uses to report the interior lighting levels to the slave node. a 4-bit value represents the brightness level required in increments of 6.65% per bit. the msb is a toggling bit that indicates whether the backlighting should be turned on or off. if this bit indicates that the lighting should be off, the brightness level is ignored and the backlighting is disabled. the lin drivers included with the reference design recognize the standard lin 1.0 system sleep request message. in lin 1.3 and later, this message is defined as part of the 0x3c ?diagnostic master request frame? message set, where the first data byte is equal to zero. currently, lin messaging scheduling tables mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 17 the application recognizes only the older version of this command (from lin 1.0) which was simply defined by the reception of identifier 0x80. when this message is received, a bit flag called linsleep is set, allowing the application to recognize this command from the master and decide how to manage network sleep conditions. the main application routine polls the flag. if the flag is set, it calls the gotosleep() routine . a small code stub has been inserted into lindriver.c to show how to expand the driver to also work with the 0x3c message style, if desired. the stub reads as follows: if (id == diagmstrreq) //defined in lindriver.h, should be 0x3c { // set a temp latch that "diagnostic master req frame" id received // then check data[0] when rcvd, if ==0x00, then set sleep flag } 2.2 scheduling tables a number of scheduling tables are defined in the ldf file. a scheduling table is a defined sequence of message frames which are sent out in a particular order at particular times. different scheduling tables are defined in the ldf file primarily to facilitate testing and debugging of the slave node. most lin tools are capable of emulating the master node in a lin network if message frames and schedule tables are defined. more advanced tool features also allow switching between schedule tables. for example: 1. run the fast_poll table (which sends the lin_stat message id) 2. whenever the lsb returns a value of 1, switch to the check_switches table (requests full button status using the 2-byte key_status frame) 3. switch back to fast_poll table to poll the node more rapidly 4. switch to lights_only for one schedule table cycle whenever the master node senses a change in the required backlighting mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 18 freescale semiconductor lin messaging table 2-2 provides a brief description of the included schedules. table 2-2. schedules included in this reference design schedule table name function fast_poll used to rapidly check node status check_switches sends only key_status request message frame to monitor key conditions lights_only sends only int_light_cmd command message frame to send backlighting settings check_switches_and_light alternately sends key_status request message frame to monitor key conditions and int_light_cmd command message frame to send backlighting settings mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 19 designer reference manual ? DRM058/d chapter 3. backlit keypad hardware 3.1 mc68hc908qy4 backlit lin slave keypad unit the hardware design for the mc68hc908qy4 backlit lin slave keypad happens to be based upon a keypad for the 2003 model ford expedition tm eddie bauer tm edition (ford replacement part#: 1l2z 9c888 ba, description: nl sw as), but any similar keypad could be used. the reference design hardware replaces the left switch unit and is designed to allow the button assembly from the factory unit to be removed and placed upon the reference design board. the right switch unit (satellite keypad) is intended to be used as is, without modification, except perhaps changing the leds and current-limiting resistors as appropriate to match the left switch unit color and intensity. to remove the existing pcb from the ford keypad, two t9 torx ? or star-drive screws must be removed. these can be found between and behind the two columns of buttons at the top and bottom of the switch unit. the torx driver must be wedged between the columns of buttons to reach the screws. torx ? is a registered trademark of camcar div. of textron inc. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 20 freescale semiconductor backlit keypad hardware figure 3-1. hc908qy4 backlit lin slave keypad unit block diagram the mc68hc908qy4 mcu has only 16 pins, including v dd and ground, and it must monitor 13 switches, communicate over the lin bus, and operate led backlighting through a pwm output. this is accomplished by combining the mcu with a lin sbc. four pins are required to connect the sbc to the mcu, but the sbc combines many functions of voltage regulation, lin physical interfacing, additional input and output circuitry, and full diagnostics and circuit protection, which compensates for using the four mcu pins. hc908qy4 lin backlit keypad satellite keypad 4 hc908qy4 mcu tx rx spi set set res res cst cst off off on on pwm led output vdd vdd atd tim vdd lin vbat gnd mc33689 lin system basis chip backlit keypad hardware mc68hc908qy4 backlit lin slave keypad unit mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 21 figure 3-2. hc908qy4 lin backlit keypad unit ? switch side (l) and component side (r) full schematic of this board can be found in the download files for this reference design and in appendix c. schematic and bom . mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 22 freescale semiconductor backlit keypad hardware 3.1.1 button interfacing the primary function of a steering wheel keypad is to monitor the status of buttons to provide an input device for the vehicle driver to easily control hvac, radio, cruise control, or other vehicle systems. the chosen base design requires 13 buttons to be monitored, which is accomplished through three different methods. buttons may be: directly input to the mcu and read as digital inputs connected to the mcu through analog-to-digital (adc) inputs and decoded from analog voltages connected directly to inputs on the sbc the three cruise control runtime functions most used by the driver are: setting a target speed (set) resuming a pre-set speed after a temporary disengagement of the cruise control (res) coasting to allow the vehicle to slow down gradually resetting the target speed (cst) the buttons controlling these three functions are set up as standard 5-v inputs directly connected to the mcu input pins with external pullup resistors to v dd . the two buttons that enable and disable the cruise control function (on and off) are connected to the sbc wake-up switch inputs with vehicle battery voltage (v bat ) level pullup resistors. this allows the buttons to be read without using additional pins on the mcu, and the status of these button inputs can be read through the spi interface to the sbc. another set of buttons is located on the satellite keypad board, which is located on the right side of the steering wheel. the buttons on this assembly are arranged in two groups of four buttons each, connected to resistor ladders which yield a different voltage depending on which button is pressed. figure 3-3 shows the block diagram of this assembly. backlit keypad hardware mc68hc908qy4 backlit lin slave keypad unit mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 23 figure 3-3. satellite keypad block diagram each of these two groups of buttons is connected through short wires within the steering wheel to adc inputs on the mcu. in this way, the mc68hc908qy4 keypad unit can determine which buttons are being pressed on the right side keypad. some combinations of multiple key-presses are possible and some might yield a different voltage; it is the function of the software to determ ine the correct interpretation of this combination. details of this are discussed in 4.3 application code . 3.1.2 led backlighting the sbc has three high-side protected drivers, allowing it to power large loads such as lamps and relays. two of these drivers (hs1 and hs2) can further be controlled through a pwm input pin, allowing a pwm signal to be anded with the switch setting. the result is the ability to pwm larger loads and loads which must be switched at v bat levels. for this reference design, all led backlighting is connected to hs1 and controlled by this driver and the pwm signal is generated on tch0 pin of the mcu?s timer. further enhancements to the backlighting can be mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 24 freescale semiconductor backlit keypad hardware accomplished through alternative circuitry and are discussed in chapter 6. design enhancements and upgrades . 3.1.3 connectors and harnesses both keypad units are separate assemblies which are mounted to opposite sides of the steering wheel, requiring a wire harness to connect them to each other and to connect to the lin bus through the clockspring mechanism. figure 3-4 shows the connections required to create the wiring harness for the keypad assembly. the connector used for the clockspring connector is a standard freescale semiconductor lin development tools connector, which allows this assembly to easily interface any of freescale?s lin master evaluation boards or lin kit boards. figure 3-4. steering wheel keypad wiring harness diagram (looking into back of harness connector?) molex pn: 39-01-2040 motorola lin connector lin vbatt gnd 45 cm molex pn: 50-57-9404 molex pn: 22-55-2081 left and right connectors use crimp terminals? molex pn: 16-02-0103 hvac switches radio switches gnd led backlight backlit keypad hardware mc68hc908qy4 backlit lin slave keypad unit mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 25 the last major hardware interface in the design is the debugging and programming interface. this connector would not be populated in production designs, and likely would not be designed into the final hardware layout, but it is provided here as a reasonable compromise for development purposes. it allows the user to reprogram the mcu, but debugging with this interface is extremely difficult due to the sharing of the pta0 pin between the pwm backlighting function and the monitor mode debugging interface. caution: do not plug the connector in backwards. doing so can cause damage to components on the board. improvements to this debugging connector interface are discussed in chapter 6. design enhancements and upgrades . mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 26 freescale semiconductor backlit keypad hardware mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 27 chapter 4. keypad slave software 4.1 overview the software for the lin keypad is fairly straightforward and covers only the basic required functions of the keypad application. this design is engineered to get a high level of performance from a relatively small and inexpensive microcontroller. as a result, there are some design challenges that are easy to overlook in the code. most of the code is written in c, but several key routines and code sequences are written in assembly code to better optimize performance. 4.2 codewarrior ? project and file structure the codewarrior 3.0 project file ( qy4_lin_keypad.mcp ), located in the sample directory, is included with this reference design and contains all the code required to build the application. the code was originally based on the mc68hc908qy4 lin drivers detailed in an2599/d: generic lin driver for mc68hc908qy4 . details on those drivers and how they can be used can be found in that application note. see chapter 7. references and acknowledgements . codewarrior ? is a registered trademark of metrowerks, inc., a wholly owned subsidiary of motorola, inc. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 28 freescale semiconductor keypad slave software figure 4-1. codewarrior 3.0 hc08 project ( qy4_lin_keypad.mcp ) the application code is contained in main.c with application-specific variable declarations, macro definitions, and data structure definitions in main.h . the lin driver consists of five files: lindriver.c ? contains the main driver code lindriver.h ? header file for the driver linapi.c ? contains all the driver api functions (only lin_init routine is used) linmsg.c ? where all lin message frames are defined tx_config.h ? header file containing the transmission pin definitions keypad slave software application code mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 29 the driver also requires these standard files and libraries: start08.c ? standard start-up routines mc68hc908qy4.h ? header file for the mc68hc908qy4 mcu mc68hc908qy4.c ? c file for the mc68hc908qy4 mcu with data structure instantiations ansi.lib ? ansi library file vector.c ? interrupt vector definitions for mcu hc08qy4.prm ? memory locations (rom and ram) in the mcu 4.3 application code the application code for the reference design is in main.c and deals with monitoring the status of the buttons, maintaining the data in the lin message buffers with this data, and updating the led backlighting pwm signal. 4.3.1 application software state machine the state diagram for the main application is shown in figure 4-2 . because the states are simple, they are not explicitly written into the application code and are shown for clarity. the state machine is event driven where all state transitions are gated by the events shown in the figure rather than by time triggering. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 30 freescale semiconductor keypad slave software figure 4-2. hc908qy4 lin backlit keypad software state diagram 4.3.2 state description the following is a detailed description of the states: start/initialize ? after reset, the software initializes the oscillator trim value to 0x00 to get the fastest possible bus clock (3.2 to 4 mhz), sets the lin driver to the unsynchronized state, sets up the timer and adc, sets up the input and output settings for the general-purpose pins, and initializes the sbc to get ready for lin messaging. additionally, the lin message buffers are cleared. main polling loop ? after in itialization is complete, the software enters the main running state. this is a polling loop that reads each of the three sets of buttons via direct inputs, sbc inputs using spi data, and adc measurements. this data is stored in a temporary latch which is transferred once to the lin message buffers at the end of the main loop. the polling loop is gated by the period of the timer module. when the timer reaches a certain period, the scheduling flag is set, which triggers one poll of the buttons. throughout the polli ng loop and every time that any delay might be encountered, the timer channel 0 flag is polled to determine whether the pwm signal requires updating. the pwm must be managed in software rather than hardware due to the sharing of the timer module and the time-critical nature of lin bus start/initialize sleep main polling loop lin network activity init done linsleep = 1 keypad slave software application code mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 31 traffic. the lin driver state machine is allowed to run while the application is in this state because this is the only time interrupts are enabled. the lin drivers are discussed in more detail in section 4.4 lin software drivers . sleep ? after successful reception and interpretation of the global lin sleep command message, the software enters the sleep state. this state serves as a trap for the sleep command. in the current design, an infinite loop is entered, but in a final design, this state would place the sbc into its sleep mode, which powers off the mcu. the state is exited only when there is message traffic on the lin bus which triggers the sbc to re-enable the regulator which causes a power-on reset (por) in the mcu. the current software also recognizes only the older, lin 1.0 form of the lin sleep command (id=0x80). 4.3.3 application data storage a description of the key data storage flow is shown in figure 4-3 . this diagram illustrates the interaction of data between the different software processes, hardware components, and system events. this diagram should be created before software is written and serves as the basis for creating all data storage structures required in the application code itself. the bubbles indicate processes that manipulate or generate data in the system. data storage locations are indi cated by text with horizontal lines above and below and use the exact nam es of the data storage structures used in the code itself (e.g., buttonlatch_1 ). in some cases, these storage areas are simply registers in the mcu memory map. in other cases, they are the lin message buffers created in ram for sending and receiving lin messages. data flow is shown as arrows with accompanying text to explain what data is being moved. all text shown in courier font corresponds to a variable or constant name used in the c code. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 32 freescale semiconductor keypad slave software figure 4-3. hc908qy4 lin backlit keypad software data flow diagram lin message transmitting code (sw drivers) message0x8b message0xca update lin message transmit buffers linstat cc_on cc_off cc_res cc_set cc_cst key_state_change radio_vol_up radio_vol_down radio_source radio_mem hvac_fan_up hvac_fan_down hvac_temp_up hvac_temp_down status_chg lin message receiving code* (sw drivers) message0x4c adr adc result register** update pwm pwmvalue read adc adlatch ad2 (pta4) ad3 (pta5) res (ptb_ptb3) set (ptb_ptb4) cst (ptb_ptb5) buttonlatch_0_prev buttonlatch_1_prev read and update button latches debounce button latches buttonlatch_0 buttonlatch_1 l1 and l2 switch inputs spireceive ptb update sbc spisend int_sbc or enter sleep mode notes: * generated or initiated by lin software drivers ** generated or updated by application code keypad slave software application code mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 33 4.3.4 choosing adc trip points for buttons to choose the ideal cutoff values for the adc measurements of the satellite keypad, calculate the net resistance of both channels for two sample units. this will provide reference resistance levels, which can be used to extrapolate adc measurements for the other points. then average the two sets of extrapolated numbers and calculate the mean value of the two resistance values desired. this final mean value will typically be the ideal adc trip point value. for example, the cutoff value for the radio_mem button was calculated as follows: 1. average estimated adc reading with radio_mem pressed: (78.8+78.6)/2 = 78.7 2. average estimated adc reading with radio_source pressed: (121.2+120.9)/2 = 121.05 3. mean adc value: (121.05+78.7)/2 = 99.875 4. hex equivalent: 0x63 table 4-1 shows the complete set of resistance measurements for both sample units, all estimated adc readings (in decimal and hexadecimal), and the calculated adc cutoff values. the net resistance measurements for the satellite keypad units were measured between pins 1?2 and pins 2?3 (radio and hvac data respectively) of the satellite keypad connector. all calculations are based on these measurements and a 1-k ? resistor to v dd located on the hc908qy4 lin keypad module. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 34 freescale semiconductor keypad slave software for a clearer understanding of these cutoff frequencies, figure 4-4 shows the extrapolated adc readings for unit 1 and unit 2 with 10% error bars and the calculated adc cutoff values to be used in the code. the calculated cutoff values (calc adc cutoff) are exactly between the adjacent resistances, which gives maximum clearance from the adjacent values and allows for the 10% possible variance in resistor values in manufacturing. table 4-1. satellite keypad resistance measurements and adc cutoff calculation data button pressed net resistance measured est. voltage reading est. adc value (dec) est. adc value (hex) calc adc cutoff unit 1 unit 2 unit 1 unit 2 unit 1 unit 2 unit 1 unit 2 dec hex radio_vol_down 74.10 73.40 0.34 0.34 17.7 17.5 11 11 30.7 1e radio_vol_up 207.30 206.50 0.86 0.86 44.0 43.8 2b 2b 61.3 3d radio_mem 445.00 443.00 1.54 1.53 78.8 78.6 4e 4e 99.9 63 radio_source 899.00 895.00 2.37 2.36 121.2 120.9 79 78 166.6 a6 keypad slave software application code mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 35 figure 4-4. adc cutoff values these cutoff target values are then used to scan through the adc readings in the code as follows: if (adlatch < 0x1e) buttonlatch_1.bits.radio_vol_down = 1; else if (adlatch < 0x3d) buttonlatch_1.bits.radio_vol_up = 1; else if (adlatch < 0x63) buttonlatch_1.bits.radio_mem = 1; else if (adlatch < 0xa6) buttonlatch_1.bits.radio_source = 1; in this way, one and only one butto n value will be chosen on each scan, and the lowest resistance will dominate. it is possible to have some combinations of multiple button presses, but some are impossible due to mechanical linkages of the buttons. due to the unlikely occurrence of these multiple button presses by the vehicle operator (these switches are generally operated with the thumbs only during vehicle operation), these cases are not addressed specifically in this reference design. the most likely combination is if the driver accidentally pressed radio_vol_down and radio_source simultaneously by pushing on the gap between them. this case would be interpreted as radio_vol_down while both buttons are pressed due to the disparity in resistance values, which is the sa fest fault condition for the system. managing all multiple button press conditions are beyond the scope of this design, but many methods can be used in software. 0.0 50.0 100.0 150.0 200.0 250.0 r a d i o _ v o l _ d o w n r a d i o _ v o l _ u p r a d i o _ m e m r a d i o _ s o u r c e < n o n e p r e s s e d > h v a c _ f a n _ d o w n h v a c _ t e m p _ u p h v a c _ f a n _ u p h v a c _ t e m p _ d o w n < n o n e p r e s s e d > unit 1 unit 2 calc adc cutoff values of unit 1 and unit 2 show estimated adc readings with 10% error bars. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 36 freescale semiconductor keypad slave software 4.3.5 software switch debouncing a very simple and effective software switch-debouncing mechanism will ensure that a button must be pressed for at least two cycles of the main polling loop. because of the way the application code is written, this will require that a button be pressed for at least 4 ms before it registers as being pressed. this is accomplished by establishing two latch buffers to hold the value of button status. the current button readings are always loaded into buttonlatch_0 and buttonlatch_1 , then they are bit-wise anded with the values from the last cycle through the polling loop stored in buttonlatch_0_prev and buttonlatch_1_prev . the resulting debounced values are loaded into the lin message buffers for transmission over the network, and finally the debounced latches are updated for the next pass through the polling loop. 4.4 lin software drivers the lin communications driver used in this reference design is essentially the same as the one found in an2599/d: generic lin driver for mc68hc908qy4 with a few changes required to speed execution time and reduce final code size. further changes to this driver or the use of another driver, such as the one in an2503/d: slave lin driver for the mc68hc908qt/qy family are detailed in chapter 6. design enhancements and upgrades . also see chapter 7. references and acknowledgements . 4.4.1 changes from lin drivers in an2599/d one of the primary changes made to the usage of the lin drivers is the added direct access of the message buffers in memory. the message buffer data structures are declared as external data structures in main.c to allow direct accesses, rather than requiring the use of the lin_putmsg() and lin_getmsg() application programming interface (api) calls. because these api calls are not used, they are not compiled; this saves code space and reduces execution performance overhead. keypad slave software lin software drivers mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 37 another change is the elimination of updating the lin message buffer status update code in the timer interrupt service routine (isr) in lindriver.c . this reduces the execution time of the isr. because the lin_putmsg() and lin_getmsg() api calls are not used to update and retrieve data in the lin message buffers, the lin message buffer status data is not updated properly or checked anyway. this renders the buffer status update code in the isr unnecessary. the only api call used in the reference design software is the lin_init() routine. several other performance improvements were made to speed execution of the timer isr which runs the lin driver. for example, the following code: for (i=0 ; i <= ((messagecounttbl[messageindex] & 0xf) - 1);i++) { framebuffer[i] = *(messagepointertbl[messageindex] + i); } was replaced with: cnt_limit = ((messagecounttbl[messageindex] & 0xf) - 1); for (i=0 ; i <= cnt_limit ;i++) { framebuffer[i] = *(messagepointertbl[messageindex] + i); } both sets of code accomplish the same end result (copying data from the lin message buffer into the temporary transmission buffer), but there is one important difference: in the first code sample, the expression (( messagecounttbl[messageindex] & 0xf) - 1 ) is evaluated each time the for () loop is executed. in the new code, the expression is evaluated one time and the loop is executed based on that value. the tradeoff is the need for one byte of stack space for the local variable cnt_limit . depending upon compiler optimizations and settings, this kind of code change might even be managed automatically. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 38 freescale semiconductor keypad slave software 4.4.2 configuring messaging the only significant detail about configuring the messaging for this design is to ensure that all transmit buffers are set up to always transmit. this is accomplished by setting the upper nibble of each entry in messagecounttbl[] for a transmit buffer to 0. 4.5 performance issues in this reference design, one timer module must be shared between two key time-critical functions, the lin bus communications and the led pwm backlighting. performance issues can arise based on the efficiency of the application and driver code, the cpu bus speed, and the speed of the lin bus communications. some aspects of code efficiency have been addressed in previous sections, particularly dealing with the execution speed of the lin driver isr. 4.5.1 lin driver isr vs. timch0 flag polling because the pwm function is managed by the application software rather than by interrupts, it is necessary to ensure that the pwm is updated often enough to maintain the pwm waveform. the worst case for this is when the pwm is at the highest or lowest duty cycle settings which are not 100% or 0%. because this is a 4-bit pwm, when pwmvalue is 0x1 or 0xe, the pwm must be updated within about 500 s (1/16 th of 8 ms). usually, this is no problem, except when lin message traffic causes many timer interrupts to occur in this same time interval as well. figure 4-5 shows what can happen when the pwm isn?t updated properly. keypad slave software performance issues mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 39 figure 4-5. missed pwm update the cursors in figure 4-5 show how wide the pwm pulse should be (notice the two normal pulses preceding it in the high-level zoom window at the top). the isrs for lin communications are shown on channel 3 and the pwm update routine is shown on channel 2. in this case, the timer isrs for the lin communications use some of the cpu cycles that were required in the 528- s window to allow the pwm update to occur. the result is that by the time the pwmfix() routine executes (channel 2), the pwm should have been low and the timer counter should have passed the target value. the pwm output stays high until the counter synchronizes. the result is an unacceptable bright flash on the led backlighting (about 16 ms). similarly, for the case where the duty cycle is 93.75% ( pwmvalue = 0xe), the led turns off for the same duration. several issues can cause this error condition, including inefficient timer isr code or insufficient polling of the pwm timer channel flag to pwm high-level zoom mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 40 freescale semiconductor keypad slave software determine whether a pwm update is needed. for these reasons, the lin timer isr performance improvements were made and very frequent polling of tch0f within the main switch polling loop is performed, especially at any point where a significant delay might occur within the switch polling loop. faster lin bus communications make the problem worse by grouping the lin-related isrs closer together as the edges of each bit come closer together. proper execution of the code can be seen in figure 4-6 . this figure shows persistence from several oscilloscope sweeps, showing several pwm cycles. figure 4-6. proper code execution of lin and pwm updates because the lin traffic is asynchronous to the application code, several ?ghosts? of previous oscilloscope sw eeps appear on both the lin rx pin (channel 1) and the lin isr indicator (channel 3). several instances of pwm high-level zoom keypad slave software performance issues mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 41 the pwmfix() routine calls are also shown on channel 2. notice that the timing of execution of this routine still varies dramatically, based on how many interrupts are being serviced for the lin communications when the pwm needs updating. in this case, however, the code has been streamlined enough to ensure that the pwm will always get serviced in time. other improvements can be made and are listed in chapter 6. design enhancements and upgrades . the indicator flags shown in figure 4-5 and figure 4-6 were generated on pins ptb4 and ptb5 as output signals, which idle at v dd and pulse low while the corresponding routine is executing. the signals were then inverted in the oscilloscope to make the resulting waveforms appear to idle low and pulse high. the reason for using the signals this way is to minimize the amount of current sourced by the mcu when the pins toggle because there is already a pullup resistor tied to the pins. these signals have been left in the code and can be activated and de-activated by enabling or disabling the debug_flags define statement in main.h . caution: do not press the set or res buttons while these flags are active. doing so will short the output pin directly to ground with no current limiting resistor. this could cause damage to the mcu. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 42 freescale semiconductor keypad slave software mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 43 chapter 5. lin master module emulation using the lin spector 5.1 overview the lin spector tool from volcano automotive group is a lin tool that can monitor and emulate lin bus traffic. with the base version of the lin spector tool, an ldf file can be read in and the master node emulated to provide message headers and bus level debugging and data monitoring. the lin spector tool is also capable of more advanced emulation and behavioral modeling, with the proper software add-on. for example, another slave node could be created to monitor the headlight switch and dimmer assembly, and a message could be added to the ldf file for the master to request this unit?s switch data. the lin spector tool can then emulate the master node and this new slave node. additionally, behavioral models of the two emulated nodes could then be programmed into a ?lin emulation control? (lec) file. this is essentially a behavioral script for the lin spector tool. a simple example is included with the download software of this reference design called led_sweep.lec . this basic script simply varies the value of the interior brightness level ( bright_lvl ) from 0x0 through 0xf and back to 0x0 constantly. each time the int_light_cmd message is sent, the next value is transmitted. the script does not control the light_on signal, so if this is 0x0, the backlighting won?t turn on at all. the result of running the script is that the backlighting pulses on and off. this isn?t practical in a vehicle, but does show some capabilities of using these kinds of tools to model node behavior. the lec file can be found in appendix b. led_sweep.lec . for details about this advanced emulation software addition, contact volcano automotive group, (http://www.volcanoautomotive.com/) mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 44 freescale semiconductor lin master module emulation using the lin spector mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 45 chapter 6. design enhancements and upgrades 6.1 overview as mentioned in other sections, there are opportunities for enhancing, upgrading, and customizing this reference design. only a brief description is offered here, as a point of departure; the designer is responsible for implementation specifics. 6.2 software performance improvements a few improvements can be made to the existing software to improve execution performance and increase the design margins of operational stability, allowing more features to be added to this code without introducing performance issues. first, the lin driver code can be further optimized to reduce its cpu requirements. this could be done by optimizing the existing drivers, writing new drivers, or using the mc68hc908qy4 lin drivers outlined in an2503/d: slave lin driver for the mc68hc908qt/qy family . the drivers in that application note require fewer interrupts, on average, for received messages, because they require only interrupts on each edge on the incoming data stream. one drawback of these drivers is that the lin bus speed must be predetermined and preprogrammed rather than using the autobauding technique found in the drivers from an2599/d. another simple change that does not require changing the software, when using the default reference design drivers, is to simply run the lin bus at a slower rate. running the bus at 9,615 bps or 10,417 bps (standard slower lin speeds for european and us manufacturers) increases the time between lin interrupts, allowing more application code to execute between isrs. this increases design margin for timing. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 46 freescale semiconductor design enhancements and upgrades a significant software change which can be made is to modify the pwmfix() routine so that if the pwm update does occur too late, the routine recognizes this condition and immediately transitions the pwm pin to the correct state. the result is that some very minor jitter might occur occasionally on one pwm cycle, but it will be approximately 1 ms rather than 16 ms based on the current design. this small amount of jitter should not be visually detectable. 6.3 software functionality upgrades a software upgrade opportunity is to complete the support for the 0x3c system sleep message and other diagnostics support. the sleep message is likely to be used by all systems and is clearly defined, so it makes sense to place support of this message directly into the driver isr. other diagnostics messages will vary between manufacturers, so it makes more sense to simply define these in linmsg.c . 6.4 hardware improvements the current hardware design could also be improved, primarily dealing with the debugging connector. one possibility is to simply remove the connector altogether, as it likely won?t be used in field applications. if it is desired to keep the connector, it could use a few improvements. currently, if the connector is plugged in backwards, the pin normally connected to pta2 (irq) would be connected to v dd , which could damage the mcu, sbc, or both. to place the part in monitor mode, high voltage (v tst ) is applied to this pin. this is anywhere from v dd +2.5 v to 9.1 v and can cause damage to components on the board. changing this connector pinout so that pta2 pin would line up with the no connect pin (currently pin 3) or keying the connector so it can?t be plugged into backwards would be a very good improvement. another issue with the debug connector is that the sbc must be powered to allow a programmer to adequately drive pta0 and pta1 to get the mcu into monitor mode. but when the sbc has v bat applied, it drives 5 v out onto v dd and the programmer cannot power-on reset the design enhancements and upgrades hardware functional upgrades mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 47 device. for debugging/development work, a cut-trace jumper on the v dd connection between the mcu and the sbc would allow the developer to disconnect this during programming. this would not be a recommended practice for production units (which would be pre-programmed or rom units anyway). 6.5 hardware functional upgrades many opportunities exist to upgrade the hardware design to introduce new features or increase performance. adding this keypad to a lin bus connection provides the freedom for the designer to implement almost any feature he or she can devise. without significantly changing the basic design, a few simple changes can be made to improve this design. the first modification would be to change the base mcu to an mc68hc908ql4 device with the slave lin interface controller (slic) module. this module is a dedicated lin peripheral which dramatically decreases lin driver code, reduces cpu overhead, and frees up the timer module to be used for the application. this application could easily fit into less than 2k bytes of code space on that device, allowing a smaller memory sized mc68hc908ql2 derivative to be used. the timer could then be used to drive the pwm channel or even two separate pwm channels for lighting buttons to different brightness levels. see to an2633/d: lin drivers for slic module on the mc68hc908ql4 for more information and example software for that mcu (in chapter 7. references and acknowledgements ) another possible change would be to use one of several multi-chip device products which contain both the mcu and the sbc. these devices combine the mcu and sbc into a single package so fewer components must be placed on the board. this also allows for smaller boards to be designed. this could also allow a larger mcu, such as the mc68hc908ey8 or mc68hc908ey16 to be designed into a smaller package, if support is needed for extra functions such as steering wheel heating and cooling or individually controlling the backlighting for each button. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 48 freescale semiconductor design enhancements and upgrades finally, a simple addition to the existing hardware design could provide for a simpler level of adaptive backlighting. three distinct backlighting zones (for cruise control, hvac, and radio) could easily be created with the addition of one or two discrete transistors and one additional wire to conn1 . this would also require a minor redesign of the satellite board to add one additional wire to separate its backlighting into two zones. both zones of the satellite board backlighting could be rerouted to be driven off hs2 rather than hs1. there is no problem with driving the pwm, as both hs1 and hs2 can be pwm controlled by the same signal on the pwmin pin of the sbc. finally, the two zones driven from hs2 could be independently gated by the discrete transistors, which are controlled via the hs3 output of the sbc and pta2 of the mcu. mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 49 chapter 7. references and acknowledgements 7.1 references freescale semiconductor?s lin site: http://freescale.com/lin mc68hc908qy4 product summary page mc33689 product summary page an2503/d: slave lin driver for the mc68hc908qt/qy family an2599/d: generic lin driver for mc68hc908qy4 an2600/d: a simple keypad using lin with the mc68hc908qt/qy mcu an2623/d: lin temperature sensor using the mc68hc908qy/qy mcu an2633/d: lin drivers for slic module on the mc68hc908ql4 lin specification, versions 1.3 and 2.0 from www.lin-subbus.org vct website: http://www.volcanoautomotive.com 7.2 acknowledgement special thanks to davor bogavac of freescale semiconductor for his invaluable assistance in creating this reference design. this reference design would not have been possible without his original designs of both the hardware and the mc68hc908qy4 lin software driver code, as well as practical advice based upon his customer-focused expertise. mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 50 freescale semiconductor references and acknowledgements mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 51 appendix a. lin_qy_backlight_keypad_messaging_strategy_1_0.ldf /****************************************************************************** copyright (c) freescale semiconductor, inc. 2001 file name: lin_qy_backlight_keypad_messaging_strategy_0_1.ldf engineer: matt ruff location: oht date created: 15 december 2003 current revision: 0.1 - 6 feb 2002 notes: lin qy backlit keypad reference design - lin description file ******************************************************************************* freescale reserves the right to make changes without further notice to any product herein to improve reliability, function or design. freescale does not assume any liability arising out of the application or use of any product, circuit, or software described herein; neither does it convey any license under its patent rights nor the rights of others. freescale products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support life, or for any other application in which the failure of the freescale product could create a situation where personal injury or death may occur. should buyer purchase or use freescale products for any such unintended or unauthorized application, buyer shall idemnify and hold freescale and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that freescale was negligent regarding the design or manufacture of the part. freescale and the freescale logo* are registered trademarks of freescale, inc. ******************************************************************************/ lin_description_file; lin_protocol_version = 1.2; lin_language_version = 1.2; //lin_speed = 4.800 kbps; //lin_speed = 9.615 kbps; //lin_speed = 10.419 kbps; //lin_speed = 16.525 kbps; lin_speed = 19.230 kbps; //-------------------------------- nodes { mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 52 freescale semiconductor /* name timebase jitter */ /* ---- -------- ------ */ master: mstr_cntl, 1 ms, 0 ms; slaves: keypad; } //-------------------------------- diagnostic_addresses {//new (1.2) //name: addr; } /*___________________________________________________________________signal definitions___*/ signals { /* name size init sender receiver(s) */ /* ---- ---- ---- ------ ----------- */ /* ------------- lin_stat signals ----------------*/ app_state_chg 5, 0, keypad, mstr_cntl; err_field 3, 0, keypad, mstr_cntl; /* ------------- key_status cruise control signals ----------------*/ cc_on 1, 0, keypad, mstr_cntl; cc_off 1, 0, keypad, mstr_cntl; cc_res 1, 0, keypad, mstr_cntl; cc_set 1, 0, keypad, mstr_cntl; cc_cst 1, 0, keypad, mstr_cntl; /* mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 53 key_status: 0x0b, keypad, 2 { /* signal offset */ /* ------ ------ */ cc_on, 0; cc_off, 1; cc_res, 2; cc_set, 3; cc_cst, 4; /* mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 54 freescale semiconductor slaverespb7, 56; } } /*___________________________________________________________________signal definitions___*/ signal_groups { //groupname: size { // signalname, offset; // } } /*___________________________________________________________________signal definitions___*/ schedule_tables { fast_poll { lin_stat delay 20.00 ms; // 10ms for 9600 bps } check_switches { key_status delay 21.00 ms; // 11ms for 9600 bps } lights_only { int_light_cmd delay 15.00 ms; // 11ms for 9600 bps } check_switches_and_light { key_status delay 15.00 ms; // 11ms for 9600 bps int_light_cmd delay 15.00 ms; // 11ms for 9600 bps } } /*___________________________________________________________________signal definitions___*/ signal_encoding_types { //name { // logical_value, signal value, "textinfo" // physical_value, min value, max value, offset, scale, "textinfo" // bcd_value ; // ascii_value ; // } app_state_chg_field { logical_value, 0, "no error"; logical_value, 1, "key was pressed"; logical_value, 2, "reserved"; logical_value, 3, "reserved"; } lin_error_field { logical_value, 0, "no error"; logical_value, 1, "reset"; logical_value, 2, "reserved"; logical_value, 3, "reserved"; logical_value, 4, "bit-error"; logical_value, 5, "checksum-err"; logical_value, 6, "byte framing error"; mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 55 logical_value, 7, "id-parity-error"; } switch_pos { logical_value, 0, "open"; logical_value, 1, "pressed"; } switch_stat_hist { logical_value, 0, "no change"; logical_value, 1, "key was pressed"; } light_level { physical_value, 0, 16, 6.65, 0, " %"; } light_status { logical_value, 0, "off"; logical_value, 1, "on"; } } /*___________________________________________________________________signal definitions___*/ signal_representation { //encname: signalname [, signalname]; app_state_chg_field: app_state_chg; lin_error_field: err_field; switch_pos: cc_on, cc_off, cc_res, cc_set, cc_cst, radio_vol_up, radio_vol_down, radio_source, radio_mem, hvac_fan_up, hvac_fan_down, hvac_temp_up, hvac_temp_down; switch_stat_hist: key_state_chg; light_level: bright_lvl; light_status: light_on; } /*___________________________________________________________________signal definitions___*/ mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 56 freescale semiconductor mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 57 appendix b. led_sweep.lec // this is a lin emulator control file // created by linspector on 1-20-2004 lin_emulation_control_file; lin_protocol_version = 1.2; lin_language_version = 1.2; lin_description_file = \\mecd-ra5782-l1\d$\data\mux_information\lin\reference design activities\qy lin slave - davor bogavac\messaging strategy\lin_qy_backlight_keypad_messaging_strategy_0_1.ldf ; emulated_nodes { mstr_cntl; } control_program { // defines: // #define // variables: // uint16 uint16 count; uint16 i; // initializations: // main cycle: while(1) { for(count= 0; count<16; count++) { bright_lvl = count; while(!test_flag(int_light_cmd.received)) { }//on int_light_cmd.received clear_flag(int_light_cmd.received); // wait for complete, then roll to next cnt // for(i=0;i<35;i++){;;} } for(count= 14; count>0; count--) { bright_lvl = count; while(!test_flag(int_light_cmd.received)) mc68hc908qy4 lin backlit keypad slave designer reference manual, rev. 1 58 freescale semiconductor { }//on int_light_cmd.received clear_flag(int_light_cmd.received); // wait for complete, then roll to next cnt // for(i=0;i<35;i++){;;} } } // while(1) } // control program mc68hc908qy4 lin backlit keypad slave designer reference manual , rev. 1 freescale semiconductor 59 appendix c. schematic and bom bill of materials (bom) designators qty description vendor part number c1 1 0.1 uf capicator (0603) digi-key pcc2277ct-nd c2 1 33 uf capicator 25v (7343) digi-key p11298ct-nd c3,c4,c5,c6,c8,c9 6 1 nf capicator (0603) digi-key pcc2151ct-nd c7 1 220 pf capicator (0603) digi-key pcc221acvct-nd d1 1 mif60 diode (sot23) digi-key zhcs1006ct-nd d2,d3,d4,d5,d6 5 red led digi-key 67-1371-1-nd conn1 1 1x4 .1oc header see note 1 and note 2 digi-key s2011-36-nd j2 1 mon08 connector 2x4 .1oc header digi-key wm18203-nd lin_con 1 1x3 .1oc header see note 1 and note 2 digi-key see conn1 r1,r2,r3,r4,r5 5 1k ohm 5% resistor (0603) digi-key 311-1.0kgct-nd r6 1 4.7 ohm resistor (0603) digi-key 311-4.7gct-nd r7,r8 2 2.32k ohm resistor (0603) digi-key p2.32khct-nd r9 1 47k ohm 5%resistor (0603) digi-key 311-47kgct-nd r10,r11 2 2k ohm 1% resistor (0805) digi-key p2.00kcct-nd r12 1 0.0 ohm 5% resistor digi-key 311-0.0gct-nd u1 1 hc908qy4 - nitron digi-key mc68hlc908qy4mdt u2 1 mc33689 - lin system basis chip digi-key pc33689dw u3 1 sm6t27ca (do214) mouser electronics 511-sm6t24ca asb525 lin keyboard bare pc board 1 bare pc board ds electronics asb525 note 1: shipped in strips of 36x2. cut to length. note 2: constructed from a 2x4 connector with one pin removed wire harness components right-harness-conn 1 c-grid sl .100 pocket header mating connector housing "g" version, 1x4 digi-key wm2902-nd 4 crimp terminals - digi-key left-harness-conn 1 c-grid crimp connector housing mating connector housing "a" version, 2x4 digi-key wm2521-nd 7 crimp terminals - digi-key clockspring-harness-conn 1 c-grid sl .100 pocket header mating connector housing "g" version, 1x3 digi-key wm2901-nd 3 crimp terminals - digi-key wm2512-nd clockspring-conn 1 c-grid sl .100 pocket header straight header digi-key wm4801-nd alternate lin master connector (motorola lin tools connector) 1 conn recept 4pos vert dual digi-key wm3701-nd 1 conn term female 18-24awg tin digi-key wm2501-nd debugging harness 1 crimp housing digi-key wm18032-nd 8 crimp terminal digi-key wm18056-nd 2003 ford expedition keypad (eddie bauer edition) 1 nl sw as ford motor company 1l2z 9c888 ba schematic 5 5 4 4 3 3 2 2 1 1 d d c c b b a a l1 l2 vbat vdd l2 vdd l1 vbat hs1 hs1 vdd vdd title size document number rev date: sheet of asb565 1.2 hc908qy4 lin sterring wheel slave keypad b 11 friday, january 16, 2004 vbat gnd lin hvac switch voltage gnd tssop tssop 25v radio switch voltage led backlight sw1 cst r5 1k d1 zhcs1006 3 1 d6 led sw4 off u1 mchc908qy4 pta5 8 pta4 9 ptb3 14 gnd 4 vdd 5 ptb1 2 ptb0 3 ptb7 6 ptb6 7 tch0 1 tch1 16 ptb2 15 rst 12 ptb4 11 pta2 13 ptb5 10 r6 4.7 c6 1nf r4 1k u2 mc33689 vs1 13 vs2 10 nc 1 nc 3 nc 12 nc 14 hs3 5 hs2 6 hs1 7 out 18 lin 11 vdd 15 e- 19 e+ 20 gnd 16 gnd 25 gnd 24 gnd 9 gnd 8 l2 4 l1 2 int 30 conf 21 reset 22 tx 32 rx 31 pwmin 23 sce 29 sck 26 mosi 27 miso 28 vcc 17 sw5 on d5 led r1 1k + c2 33 uf r9 47k c3 1nf sw3 res r10 2k r3 1k sw2 set lin_con 3-pin_lin_power 1 1 2 2 3 3 d2 led r2 1k r7 2.3k u3 sm6t27ca c9 1nf c4 1nf d4 led c7 220pf c1 0.1 d3 led j2 mon08 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 c8 1nf r8 2.3k c5 1nf conn1 1x4 connector pin1 1 pin3 3 pin4 4 pin2 2 r12 0 r11 2k DRM058 rev. 1, 7/2004 how to reach us: usa/europe/locations not listed: freescale semiconductor literature distribution p.o. box 5405, denver, colorado 80217 1-800-521-6274 or 480-768-2130 japan: freescale semiconductor japan ltd. sps, technical information center 3-20-1, minami-azabu minato-ku tokyo 106-8573, japan 81-3-3440-3569 asia/pacific: freescale semiconductor h.k. ltd. 2 dai king street tai po industrial estate ta i po, n . t. h o n g ko n g 852-26668334 learn more: for more information about freescale semiconductor products, please visit http://www.freescale.com information in this document is provided solely to enable system and software implementers to use freescale semiconductor products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. freescale semiconductor reserves the right to make changes without further notice to any products herein. freescale semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does freescale semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. ?typical? parameters which may be provided in freescale semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. all operating parameters, including ?typicals? must be validated for each customer application by customer?s technical experts. freescale semiconductor does not convey any license under its patent rights nor the rights of others. freescale semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the freescale semiconductor product could create a situation where personal injury or death may occur. should buyer purchase or use freescale semiconductor products for any such unintended or unauthorized application, buyer shall indemnify and hold freescale semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that freescale semiconductor was negligent regarding the design or manufacture of the part. freescale? and the freescale logo are trademarks of freescale semiconductor, inc. all other product or service names are the property of their respective owners. ? freescale semiconductor, inc. 2004. |
Price & Availability of DRM058
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |