AN2262 Motorola / Freescale Semiconductor, AN2262 Datasheet

no-image

AN2262

Manufacturer Part Number
AN2262
Description
Wireless HC08 Modem
Manufacturer
Motorola / Freescale Semiconductor
Datasheet
Application Note
AN2262/D
Rev. 1, 6/2002
Wireless HC08 Modem
By Pavel Lajsner
Introduction
Design Overview
Motorola Czech System Application Laboratory
Roznov pod Radhostem, Czech Republic
This document details the hardware and software required for a low-cost
wireless communication application based on:
The main purpose of this document is to demonstrate the ability of the 8-bit
MCU to be connected by means of a wireless medium. Or, in other words, how
you can connect several HC08s forming a simple wireless network.
The RF communication is analyzed first, then the configuration of the chips, the
RF protocol, and finally the software techniques are discussed. All embedded
software was written using the Hi-Ware ANSI-C/cC++ Compiler for HC08 from
Metrowerks®
‘The wireless HC08 modem’ is targeted as one possible communication
medium for a complete ‘home interconnectivity’ system.
1. The MC33491 (code name Tango II) is no longer available. The MC33493 (code name
2. Metrowerks is a registered trademark of Metrowerks, Inc., a wholly owned subsidiary of
Tango III) is it’s full replacement. For a more detailed description, refer to the footnote on
page 4
Motorola, Inc.
The Motorola 8-bit microcontroller (MCU), MC68HC908GP32
Accompanied by the Motorola RF (radio frequency) chip set:
and to the
MC33493 (transmitter)
MC33591/3 (receiver)
(2)
Software (
MC33491 to MC33493 Migration Notes on page
http://www.metrowerks.com
(1)
).
36.
© Motorola, Inc., 2002

Related parts for AN2262

AN2262 Summary of contents

Page 1

... Application Note AN2262/D Rev. 1, 6/2002 Wireless HC08 Modem By Pavel Lajsner Motorola Czech System Application Laboratory Roznov pod Radhostem, Czech Republic Introduction This document details the hardware and software required for a low-cost wireless communication application based on: • • The main purpose of this document is to demonstrate the ability of the 8-bit MCU to be connected by means of a wireless medium ...

Page 2

... AN2262/D The example system (shown in communicates with the Internet on one side and with numerous embedded devices (e.g., at home) on the other side. The main idea on the background is that it’s not necessary to connect all such small devices directly over IP (Internet protocol). Although well-established and known, IP has several disadvantages which don’ ...

Page 3

... Two generic function LEDs and two LEDs indicating activity on the serial interface have been added. MOTOROLA Three light emitting diodes (LED) — red, yellow, green Three accompanying push buttons A buzzer An optical sensor A knob An RS232/RS485 serial interface Wireless HC08 Modem AN2262/D Hardware Platform 3 ...

Page 4

... AN2262/D Radio Frequency For wireless communication, the Motorola RF chip set is used. (RF) • • These low-cost, single-channel chips for ISM bands were originally designed for key fob applications used in the car industry. The high integration, low component count adjustment, and low cost allow its use in such cost- sensitive applications like home connectivity ...

Page 5

Figure 2. Application Schematic + + + + Wireless HC08 modem ...

Page 6

... AN2262/D Power Supply The D13 diode protects the complete circuit from reverse voltage. The MCU operating voltages V C6, C7, and C8 close to the MCU on their respective ground pins. They are all driven from the regulated 5-volt V The MC33491 chip requires a 3-volt power supply, provision is made for a ...

Page 7

... The paired signals RTS and CTS provide information about whether the remote device is temporarily unable to receive data serial communication uses these signals, it’s called “hardware handshake” or “hardware flow control”. Wireless HC08 Modem AN2262/D Hardware Platform SPI Communication which also describes 36.) ...

Page 8

... AN2262/D Signal Name TXD RXD RTS CTS DTR DSR GND Signal Name TXD RXD RTS CTS DTR DSR GND User RS485 Ports The user RS485 current loop serial port looks simple but is relatively more complicated to connect and configure. It consists of: • • ...

Page 9

... Leave JP3 open – Connect JP4 1-2 if 120- – Connect JP4 3-4 if 120- – Connect JP5 1-2 – Leave JP6 open Wireless HC08 Modem Hardware Platform ). http://www.maxim-ic.com load required, otherwise all open TX load required (not usually) RX load required (usually) AN2262/D ®(1) 9 ...

Page 10

... AN2262/D Bill of Materials Table 3 Quantity 10 summarizes all components assembled for the RF-08 application: Table 3. Bill of Materials (Sheet Reference BZ1 2 C1 C5, C15 C6, C7, C8, C10, C16, C24, (1) (2) (2) 14 C26 , C27 , C28 , C29 (2) C30 , C33, C35, C37 3 C9, C18,C19 ...

Page 11

... CON/Power Jack small Farnell 224-674 CON/Cannon 9 — female Farnell 892-452 CON/Cannon 9 — male Farnell 892-439 8 GND 50 k trimmer Farnell 347-346 BC846ALT1 47 k 330 2 1.5 k 180 k / R/opto Farnell 316-8335 (1) 120 2.7 k MC33491DTB (Motorola) RF2436 (RF Micro Devices) AN2262/D 11 ...

Page 12

... AN2262/D Quantity 1. Components are NOT assembled in RS232 mode. See Configurations. 2. Components are NOT assembled in RS485 mode. See Configurations. NOTE: All SMD capacitors and resistors are of standard 0805 size, unless otherwise specified. For power connection to J1 use Farnell 224-911 cable end. The MC33491 is no longer available. See ...

Page 13

... The board thickness as well as the copper thickness are not critical and standard sizes are used. See MOTOROLA Figure 2. Figure Figure 3. Bottom Copper Side Wireless HC08 Modem Application Schematic 3, Figure 4, and Figure 5. AN2262/D 13 ...

Page 14

... AN2262/D 14 Figure 4. Top Copper Side Figure 5. PCB Silk Screen Wireless HC08 Modem MOTOROLA ...

Page 15

... MOTOROLA RF Chip Set MC33491/MC33493/MC33591/3 and RF Protocol Figure 6. MC33491/MC33493 Application Schematic Quartz (X2) and the required capacitor (C4) An impedance matching inductor (L1 path DC decoupling capacitor (C5) A choke (L2) to bias output stage A resistor (R7) controls the output power Wireless HC08 Modem AN2262/D Figure 6. 15 ...

Page 16

... AN2262/D MC33491/MC33493 The MC33491/MC33493 has several operation modes. A simple control mode Control Mode is useful when only on-off keying (OOK) modulation is required and the Manchester coding capability of the MC33491/MC33493 is not used. For detailed information on all modes, refer to the MC33493 Data Sheet (Motorola order number, MC33493/D) ...

Page 17

... C16, C17, and C18 are decoupling capacitors R24, C20, and C21 are PLL filters L3, L4, and C19 form receive RF path impedance matching C14, C24, and R24 are miscellaneous external components required for correct receiver operation Wireless HC08 Modem AN2262/D Figure 8. As the 17 ...

Page 18

... AN2262/D AGC Capacitor A new phenomena is introduced when MC33493 and MC33591/3 chips are Discharge assembled into one application. MC33591/3 (as an ASK (OOK) system) the demodulation is performed by an envelope detector. This block (and also some others along the signal path) are sensitive to the signal strength and they also employ a certain time constant ...

Page 19

... RF-08 FRAME #1 SCI RF FRAME #2 MOTOROLA AGC HEADER SETTLING SPI CLOCK SPI DATA Figure 9. RF Protocol LEN FRAME #1 CRC LEN FRAME #2 Figure 10. Frame Handling Wireless HC08 Modem PAY-LOAD EOM RF-08 Figure 10. RF-08 SCI RF CRC AN2262/D Software Protocol. FRAME #1 FRAME #2 19 ...

Page 20

... AN2262/D RF Transmission For operation of the MC33493 transmitter chip it is necessary to control two lines in the minimal configuration: • • The basic principle of Manchester encoding is that each bit is divided into two halves. The level in the first period is the same as in the original NRZ (non- return to zero) stream while the level in the second period is inverted ...

Page 21

... TIM. The central component of each TIM PRESCALER SELECT PS2 PS1 PS0 ELS0B ELS0A CH0F MS0A MS0B ELS1B ELS1A CH1F MS1A Figure 12. TIM Block Diagram Wireless HC08 Modem AN2262/D Software INTER- TOF RUPT LOGIC TOIE TOV0 PORT CH0MAX PTA2/KBD2/TCH0 LOGIC INTER- RUPT LOGIC CH0IE ...

Page 22

... AN2262/D Symbolic Renaming During coding, the intention was to make the source code independent of which of TIM Registers channel and which timer module is used for generating the Manchester encoded data stream. Also some indicators and other peripherals might be different on different hardware platforms. To keep the source code the same, symbolic, function related names of TIM registers and peripherals (e ...

Page 23

... MOTOROLA PERIOD PULSE WIDTH OUTPUT COMPARE wem.h #define BUS_CLOCK_HZ 3686400 rf2.h #define RF_SPEED 9600L #define RF_FULLBIT (BUS_CLOCK_HZ)/RF_SPEED #define RF_HALFBIT (BUS_CLOCK_HZ)/(2*RF_SPEED) shows how the Manchester encoding is handled. When the timer Wireless HC08 Modem OUTPUT OUTPUT COMPARE COMPARE AN2262/D Software 23 ...

Page 24

... AN2262/D OUTPUT COMPARE OC ISR = Output Compare Interrupt Service Routine This method is insensitive to any latencies which may occur (e.g., when some other source of interrupt is being serviced). The only limitation is that the actual OC interrupt service routine must complete before the next output compare event occurs. This is demonstrated in ...

Page 25

... FLAG FEED TxChar AND TxBits NO WITH CORRECT PREAMBLE VALUES CLEAR ‘PREAMBLE’ FLAG RETURN YES ‘HEADER’ FLAG FEED TxChar AND TxBits NO WITH CORRECT HEADER VALUES TXFINISH() CLEANUP CLEAR ‘HEADER’ FLAG CLEAR RFTIMERTXD_INT FLAG RETURN RETURN AN2262/D Software 25 ...

Page 26

... AN2262/D Figure 16 RF TRANSMISSION ‘PREAMBLE’ FLAG ‘HEADER’ FLAG RF-08 Protocol The RF-08 protocol used in this application is truly simple. Every frame sent over RF consists of three fields length field (8 bit value), the length of a complete frame including the 2. Data (variable length), limited by memory restrictions of the CPU 3 ...

Page 27

... MC33591/3 is the slave MC33591 normal (reception) mode, then MC33591/3 is the master leaving the MCU the slave role. This is relative to the SPI operation. MOTOROLA crc = ((crc >> 8) & 0xff) ^ crc_table[(crc ^ *buf++) & 0xff]; Wireless HC08 Modem AN2262/D Software MC33591/3 Receiver SPI Interface describes the 27 ...

Page 28

... AN2262/D The differentiation between these two modes is driven by the MCU. The input RESETB pin of MC33591/3 tells it whether the receiver is being configured (and its SPI is in slave mode should work in normal mode (its SPI is in master mode). RESETB is connected to the general-purpose I/O pin of the MCU in output mode ...

Page 29

... The CRC calculated over the complete buffer is 0. Wireless HC08 Modem Figure 19. DATA #N EOM DATA #N EOM RF_RXTIMEOUT TIMER TIMER TIMER TIMER RESET RESET RESET REACHED THRESHOLD rf2.h RF-08 Protocol. AN2262/D Software 29 ...

Page 30

... AN2262/D SCI Operation Another part of the application is the serial communication interface (SCI). A set of universal routines have been used within this application. The main features configurable at compile time are: • • • • • All functions are declared in required, the timing features are defined through one function in tbm ...

Page 31

... SCI or RF. Data is then scheduled to be transmitted to the ‘opposite’ media. All other tasks are interrupt driven as previously described (SCI transmit, SCI receive, RF transmit, and RF receive). See MOTOROLA # Figure 20. SCI Timeout Explanation Wireless HC08 Modem AN2262/D Software Figure 20). Figure 21. 31 ...

Page 32

... AN2262/D RF DATA SENT SCI DATA RECEIVED (SCI TIMEOUT OCCURRED) RF DATA SENDING DONE, RF TRANSFER INITIATED SCI DATA TRANSFER TO RF BUFFER ADD LENGTH + CRC FIELDS If a user wishes to implement his own application for an end RF application, some sort of application protocol needs to be implemented and then the main ...

Page 33

... RF-08 board. Where the end device sits on one side of the communication channel Where the client control terminal or host computer (for example, personal computer) is located Wireless HC08 Modem AN2262/D Wireless HC08 Modem Testing & Demonstration 33 ...

Page 34

... AN2262/D For demonstration purposes, the personal computers with terminal programs running are used on both sides of communication channel; first one as the end device while the second one acts as the control terminal. For this configuration, one PC with either two serial (COM) ports or two PCs has to be used. ...

Page 35

... To obtain the most up-to-date information, refer to: Motorola, Inc. — Maxim Integrated Products — RF Micro Devices Incorporated — MOTOROLA MC68HC908GP32/D) entitled “A Tutorial on CRC Computations“ Recommendations (Motorola order number, AN2195/D) http://www.motorola.com/semiconductors/ http://www.maxim-ic.com Wireless HC08 Modem http://www.rfmd.com AN2262/D References 35 ...

Page 36

... AN2262/D MC33491 to MC33493 Migration Notes The MC33491 (code name Tango II longer available ( 2002). The MC33493 (code name Tango III) is it’s full replacement and within full 3 V-only environment there’s no change between the basic configurations of these two. The MC33493 input pins are not specified above V MC33493 cannot be used within described RF-08 schematics that employ R1 and R3 serial resistors to protect MC33493 3-V interface ...

Page 37

SMC2 RX SMC2 TX Figure 24. Application Schematic Using MC33493 (Tango III) RPX Lite UART expansion board - FRED II RF interface ...

Page 38

... AN2262/D Source Code board.h /********************************************************************** * HEADER_START * * Name: BOARD.H * Project: Interconnectivity SRDT * Description: Wireless RS232 board header file * Processor: HC08 * Revision: 1.0 * Date: Feb 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG * Author: Michal Hanak * Company: Motorola SPS * Security: General Business * * =================================================================== * * Copyright (c): MOTOROLA Inc., 2001, All rights reserved. ...

Page 39

... RFDchrgCAgcOff() #define RFDchrgCMixAgcOff() MOTOROLA // all inputs // all inputs // all outputs // d0-d3 inputs; d4-d7 outputs // e0-e1 inputs // output to TANGO2 // output to TANGO2 // output to ROMEO2 // output to ROMEO2 // port DCHRG ROMEO2 // DDR MASK DCHRG ROMEO2 RF_DCHRDDR &= ~RF_DCHRGMASK RF_DCHRDDR |= RF_DCHRGMASK RF_DCHRGCMIXAGC = 0 Wireless HC08 Modem AN2262/D Source Code */ */ */ */ */ 39 ...

Page 40

... AN2262/D #define IfBtnJp1BuzzerOn() #define IfBtnJp1BuzzerOff() #define RFTimerCTRL T1SC #define RFTimerCTRL_TOF T1SC_TOF #define RFTimerCTRL_TOIE T1SC_TOIE #define RFTimerTMOUT T1SC0 #define RFTimerTMOUT_CHF T1SC0_CH0F #define RFTimerTMOUT_CHIE T1SC0_CH0IE #define RFTimerTMOUT_TOV T1SC0_TOV0 #define RFTimerTMOUT_MSA T1SC0_MS0A #define RFTimerTMOUT_ELSB T1SC0_ELS0B #define RFTimerTMOUT_ELSA T1SC0_ELS0A #define RFTimerTXD T1SC1 #define RFTimerTXD_CHF T1SC1_CH1F ...

Page 41

... RFDchrgInputs() #define RFDchrgOutputs() #define StrobeEnable() #define RFModeDisable() #define RFDchrgCAgcOff() #define RFDchrgCMixAgcOff() MOTOROLA // output to TANGO2 // output to TANGO2 // output to ROMEO2 // output to ROMEO2 // port DCHRG ROMEO2 // DDR MASK DCHRG ROMEO2 RF_DCHRDDR &= ~RF_DCHRGMASK RF_DCHRDDR |= RF_DCHRGMASK RF_DCHRGCMIXAGC = 0 Wireless HC08 Modem AN2262/D Source Code /**/ 41 ...

Page 42

... AN2262/D #define IfBtnJp1BuzzerOn() #define IfBtnJp1BuzzerOff() #define RFTimerCTRL T2SC #define RFTimerCTRL_TOF T2SC_TOF #define RFTimerCTRL_TOIE T2SC_TOIE #define RFTimerTXD T2SC0 #define RFTimerTXD_CHF T2SC0_CH0F #define RFTimerTXD_CHIE T2SC0_CH0IE #define RFTimerTXD_TOV T2SC0_TOV0 #define RFTimerTXD_MSA T2SC0_MS0A #define RFTimerTXD_ELSB T2SC0_ELS0B #define RFTimerTXD_ELSA T2SC0_ELS0A #define RFTimerTMOUT T2SC1 #define RFTimerTMOUT_CHF T2SC1_CH1F ...

Page 43

... RFModeDisable() RF_MODE = 0 #define RFDchrgCAgcOff() #define RFDchrgCMixAgcOff() MOTOROLA // output to TANGO2 // output to TANGO2 // output to TANGO2 // output to ROMEO2 // output to ROMEO2 // output to ROMEO2 // output to ROMEO2 // port DCHRG ROMEO2 // DDR MASK DCHRG ROMEO2 RF_DCHRDDR &= ~RF_DCHRGMASK RF_DCHRDDR |= RF_DCHRGMASK RF_STROBE = 1 RF_DCHRGCAGC = 0 RF_DCHRGCMIXAGC = 0 Wireless HC08 Modem AN2262/D Source Code /**/ 43 ...

Page 44

... AN2262/D #define IfBtnJp1BuzzerOn() #define IfBtnJp1BuzzerOff() #define RFTimerCTRL T2SC #define RFTimerCTRL_TOF T2SC_TOF #define RFTimerCTRL_TOIE T2SC_TOIE #define RFTimerTXD T2SC0 #define RFTimerTXD_CHF T2SC0_CH0F #define RFTimerTXD_CHIE T2SC0_CH0IE #define RFTimerTXD_TOV T2SC0_TOV0 #define RFTimerTXD_MSA T2SC0_MS0A #define RFTimerTXD_ELSB T2SC0_ELS0B #define RFTimerTXD_ELSA T2SC0_ELS0A #define RFTimerTMOUT T2SC1 #define RFTimerTMOUT_CHF T2SC1_CH1F ...

Page 45

... This still does not guarentee that the compiler will execute each assignment exactly as coded, as some compilers MOTOROLA IN NO EVENT SHALL MOTOROLA OR Wireless HC08 Modem AN2262/D Source Code * * * * ...

Page 46

... AN2262/D may still try to optimize volatile bytes. The compiler should be tested with this header file to ensure register assignments are not optimized. Bitfields Each bit is defined using the following format: REGISTERNAME_BITNAME While this may result in redundant names in some cases, it will always prevent duplicate bit names bit has a descriptive name such as FLG the descriptive name is used ...

Page 47

... Port B Data register */ #define PTB REGISTER(0x01) #define PTB_BIT0 BIT(0x01,0) #define PTB_BIT1 BIT(0x01,1) #define PTB_BIT2 BIT(0x01,2) #define PTB_BIT3 BIT(0x01,3) #define PTB_BIT4 BIT(0x01,4) #define PTB_BIT5 BIT(0x01,5) #define PTB_BIT6 BIT(0x01,6) #define PTB_BIT7 BIT(0x01,7) MOTOROLA : Wireless HC08 Modem AN2262/D Source Code */ */ 47 ...

Page 48

... AN2262/D /* Port C Data register */ #define PTC REGISTER(0x02) #define PTC_BIT0 BIT(0x02,0) #define PTC_BIT1 BIT(0x02,1) #define PTC_BIT2 BIT(0x02,2) #define PTC_BIT3 BIT(0x02,3) #define PTC_BIT4 BIT(0x02,4) #define PTC_BIT5 BIT(0x02,5) #define PTC_BIT6 BIT(0x02,6) /* Port D Data register */ #define PTD REGISTER(0x03) #define PTD_BIT0 BIT(0x03,0) #define PTD_BIT1 BIT(0x03,1) #define ...

Page 49

... Port C Pull Up Enable Register */ #define PTCPUE #define PTCPUE_BIT0 #define PTCPUE_BIT1 #define PTCPUE_BIT2 #define PTCPUE_BIT3 #define PTCPUE_BIT4 #define PTCPUE_BIT5 #define PTCPUE_BIT6 MOTOROLA REGISTER(0x0d) BIT(0x0d,0) BIT(0x0d,1) BIT(0x0d,2) BIT(0x0d,3) BIT(0x0d,4) BIT(0x0d,5) BIT(0x0d,6) BIT(0x0d,7) REGISTER(0x0e) BIT(0x0e,0) BIT(0x0e,1) BIT(0x0e,2) BIT(0x0e,3) BIT(0x0e,4) BIT(0x0e,5) BIT(0x0e,6) Wireless HC08 Modem AN2262/D Source Code 49 ...

Page 50

... AN2262/D /* Port D Pull Up Enable Register */ #define PTDPUE REGISTER(0x0f) #define PTDPUE_BIT0 BIT(0x0f,0) #define PTDPUE_BIT1 BIT(0x0f,1) #define PTDPUE_BIT2 BIT(0x0f,2) #define PTDPUE_BIT3 BIT(0x0f,3) #define PTDPUE_BIT4 BIT(0x0f,4) #define PTDPUE_BIT5 BIT(0x0f,5) #define PTDPUE_BIT6 BIT(0x0f,6) #define PTDPUE_BIT7 BIT(0x0f,7) /****************************************************************************/ /* Serial Peripheral Interface Registers /****************************************************************************/ /* SPI Control Register */ #define SPCR ...

Page 51

... BIT(0x14,1) BIT(0x14,2) BIT(0x14,3) BIT(0x14,4) BIT(0x14,5) BIT(0x14,6) BIT(0x14,7) REGISTER(0x15) BIT(0x15,0) BIT(0x15,1) BIT(0x15,2) BIT(0x15,3) BIT(0x15,4) BIT(0x15,5) BIT(0x15,6) BIT(0x15,7) REGISTER(0x16) BIT(0x16,0) BIT(0x16,1) BIT(0x16,2) BIT(0x16,3) BIT(0x16,4) BIT(0x16,5) BIT(0x16,6) BIT(0x16,7) REGISTER(0x17) BIT(0x17,0) BIT(0x17,1) REGISTER(0x18) REGISTER(0x19) BIT(0x19,0) BIT(0x19,1) BIT(0x19,2) BIT(0x19,4) BIT(0x19,5) Wireless HC08 Modem AN2262/D Source Code 51 ...

Page 52

... AN2262/D /****************************************************************************/ /* Keyboard Registers /****************************************************************************/ /* Keyboard Status and Control Register */ #define INTKBSCR #define INTKBSCR_MODEK #define INTKBSCR_IMASKK #define INTKBSCR_ACKK #define INTKBSCR_KEYF /* Keyboard Interrupt Enable Register */ #define INTKBIER #define INTKBIER_KBIE0 #define INTKBIER_KBIE1 #define INTKBIER_KBIE2 #define INTKBIRE_KBIE3 #define INTKBIER_KBIE4 #define INTKBIER_KBIE5 #define INTKBIER_KBIE6 #define INTKBIER_KBIE7 /****************************************************************************/ ...

Page 53

... T1SC0_TOV0 BIT(0x25,1) #define T1SC0_ELS0A BIT(0x25,2) #define T1SC0_ELS0B BIT(0x25,3) #define T1SC0_MS0A BIT(0x25,4) #define T1SC0_MS0B BIT(0x25,5) #define T1SC0_CH0IE BIT(0x25,6) #define T1SC0_CH0F BIT(0x25,7) /* Timer Channel 0 Register */ #define T1CH0 DBLREG(0x26) MOTOROLA REGISTER(0x20) BIT(0x20,0) BIT(0x20,1) BIT(0x20,2) BIT(0x20,4) BIT(0x20,5) BIT(0x20,6) BIT(0x20,7) */ Wireless HC08 Modem AN2262/D Source Code */ */ */ */ */ 53 ...

Page 54

... AN2262/D #define T1CH0H REGISTER(0x26) #define T1CH0L REGISTER(0x27) /* Timer Status and Control Register Channel 1 */ #define T1SC1 REGISTER(0x28) #define T1SC1_CH1MAX BIT(0x28,0) #define T1SC1_TOV1 BIT(0x28,1) #define T1SC1_ELS1A BIT(0x28,2) #define T1SC1_ELS1B BIT(0x28,3) #define T1SC1_MS1A BIT(0x28,4) #define T1SC1_CH1IE BIT(0x28,6) #define T1SC1_CH1F BIT(0x28,7) /* Timer Channel 1 Register */ #define ...

Page 55

... BIT(0x36,1) #define PCTL_PRE0 BIT(0x36,2) #define PCTL_PRE1 BIT(0x36,3) #define PCTL_BCS BIT(0x36,4) #define PCTL_PLLON BIT(0x36,5) #define PCTL_PLLF BIT(0x36,6) #define PCTL_PLLIE BIT(0x36,7) /* PLL Bandwidth Register */ #define PBWC REGISTER(0x37) #define PBWC_ACQ BIT(0x37,5) #define PBWC_LOCK BIT(0x37,6) #define PBWC_AUTO BIT(0x37,7) MOTOROLA Wireless HC08 Modem AN2262/D Source Code */ 55 ...

Page 56

... AN2262/D /* PLL Multiplier High Register */ #define PMSH REGISTER(0x38) /* PLL Multiplier Low Register */ #define PMSL REGISTER(0x39) /* PLL VCO Select Range Register */ #define PMRS REGISTER(0x3a) /* PLL Reference Divider Select Register */ #define PMDS REGISTER(0x3b) /****************************************************************************/ /* Analogue To Digital Converter Registers /****************************************************************************/ /* A/D Status and Control Register */ #define ADSCR ...

Page 57

... BIT(0xFE05,0) #define INT2_IF8 BIT(0xFE05,1) #define INT2_IF9 BIT(0xFE05,2) #define INT2_IF10 BIT(0xFE05,3) #define INT2_IF11 BIT(0xFE05,4) #define INT2_IF12 BIT(0xFE05,5) #define INT2_IF13 BIT(0xFE05,6) #define INT2_IF14 BIT(0xFE05,7) /* Interrupt Status Register 3 */ #define INT3 REGISTER(0xFE06) #define INT3_IF15 BIT(0xFE06,0) #define INT3_IF16 BIT(0xFE06,1) MOTOROLA Wireless HC08 Modem AN2262/D Source Code */ 57 ...

Page 58

... AN2262/D /****************************************************************************/ /* Flash Registers /****************************************************************************/ /* Flash Control Register 1 */ #define FLCR REGISTER(0xFE08) #define FLCR_PGM BIT(0xFE08,0) #define FLCR_ERASE BIT(0xFE08,1) #define FLCR_MASS BIT(0xFE08,2) #define FLCR_HVEN BIT(0xFE08,3) #define M_FLCR_PGM BIT0 #define M_FLCR_ERASE BIT1 #define M_FLCR_MARGIN BIT2 #define M_FLCR_HVEN BIT3 /* Flash Block Protect Register 1 */ #define FLBPR REGISTER(0xFF7E) #define ...

Page 59

... MOTOROLA /* Time Base Module /* Analogue To Digital Converter /* Keyboard /* Serial Communication Transmit /* Serial Communication Receive /* Serial Communication Error /* SPI Transmit /* SPI Receive /* Timer B Channel 1 /* Timer B Channel 0 /* Modulo B Timer /* Timer A Channel 1 Wireless HC08 Modem AN2262/D Source Code */ */ */ */ */ */ */ */ */ */ */ */ ...

Page 60

... AN2262/D #define IV_T1CH1 5 #define IV_T1CHO 4 #define IV_PLL 3 #define IV_IRQ1 2 #define IV_SWI 1 #define IV_RESET 0 #endif 60 /* Timer A Channel 0 /* Modulo A Timer /* Phase Locked Loop /* Interrupt Request1 /* Software Interrupt /* Reset Wireless HC08 Modem */ */ */ */ */ */ MOTOROLA ...

Page 61

... Romeo header #define RF_HEADER_BITS #define RF_HEADER 0xc8 // preamble initiating transmission #define RF_PREAMBLE 0xff #define RF_PREAMBLE_BITS 8 #if !defined(BUS_CLOCK_HZ) MOTOROLA IN NO EVENT SHALL MOTOROLA OR 0x8 Wireless HC08 Modem AN2262/D Source Code * * * * * * * * * * * * * ...

Page 62

... AN2262/D #error “RF: need BUS_CLOCK_HZ symbol defined” #endif // single bit length #ifndef RF_SPEED #define RF_SPEED 9600L #endif #ifndef RF_FULLBIT #define RF_FULLBIT (BUS_CLOCK_HZ)/RF_SPEED #endif #define RF_HALFBIT (BUS_CLOCK_HZ)/(2*RF_SPEED) #define RF_TAILLEN 10L*RF_FULLBIT #define RF_RXTIMEOUT 16L*RF_FULLBIT ////////////////////////////////////////////////////////// // macros #define RF_R2CFG_HE 0x01 #define RF_R2CFG_DME ...

Page 63

... RF_Init(BYTE* romeoCfg); // initiate transmission void RF_TxStart(void); // initiate reception void RF_RxStart(void); void RF_RxStop(void); // user interrupt-time call-backs prototypes void RF_TxChar_Int(void); void RF_TxFinish_Int(void); void RF_TxFinish(void); void RF_RxChar_Int(BYTE ch); void RF_TxChar(BYTE tx); BYTE RF_RxBuff_OK(void); void RF_SendBuff(BYTE len); #endif MOTOROLA RFTimerTXD_TOV=1; Wireless HC08 Modem AN2262/D Source Code 63 ...

Page 64

... AN2262/D sci.h /********************************************************************** * HEADER_START * * Name: SCI.H * Project: Interconnectivity SRDT * Description: SCI control * Processor: HC08 * Revision: 1.1 * Date: Apr 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG * Author: Michal Hanak * Company: Motorola SPS * Security: General Business * * =================================================================== * * Copyright (c): MOTOROLA Inc., 2001, All rights reserved =================================================================== * * THIS SOFTWARE IS PROVIDED BY MOTOROLA “ ...

Page 65

... SCI_CTS port-bit not defined” #endif #if !defined(SCI_CTS_OFF) || !defined(SCI_CTS_ON) #error “SCI: SCI_CTS ON-OFF states not defined” #endif #endif // SCI_CTS_CONTROL #if defined(SCI_RTS_CONTROL) #if !defined(SCI_RTS) #error “SCI: SCI_RTS port-bit not defined” #endif #if !defined(SCI_RTS_OFF) || !defined(SCI_RTS_ON) MOTOROLA Wireless HC08 Modem AN2262/D Source Code 65 ...

Page 66

... AN2262/D #error “SCI: SCI_RTS ON-OFF states not defined” #endif // RTS is not yet implemented ! #error “SCI: SCI_RTS_CONTROL is not yet implemented” #endif // SCI_RTS_CONTROL #if defined(SCI_TXE_CONTROL) #if !defined(SCI_TXE) #error “SCI: SCI_TXE port-bit not defined” #endif #if !defined(SCI_TXE_OFF) || !defined(SCI_TXE_ON) #error “SCI: SCI_TXE ON-OFF states not defined” ...

Page 67

... SCI clock 14745600 // 230400 // 115200 0x10 // 76800 0x02 // 57600 0x11 // 38400 0x03 // 28800 0x12 // 19200 0x04 // 14400 0x13 // 9600 0x05 // 7200 0x14 // 4800 Wireless HC08 Modem AN2262/D Source Code 67 ...

Page 68

... AN2262/D #define SCI_SCBR_3600 0x06 #define SCI_SCBR_2400 0x15 #define SCI_SCBR_1800 0x07 #define SCI_SCBR_1200 0x16 #elif SCI_CLOCK_HZ==16000000 #define SCI_SCBR_19200 0x30 #define SCI_SCBR_9600 0x31 #define SCI_SCBR_4800 0x32 #define SCI_SCBR_2400 0x33 #define SCI_SCBR_1200 0x34 #elif SCI_CLOCK_HZ==19660800 #define SCI_SCBR_307200 0x00 #define SCI_SCBR_153600 0x01 #define SCI_SCBR_76800 ...

Page 69

... SCI_InitTx(BYTE* buff, BYTE size); void SCI_InitRx(BYTE* buff, BYTE size); #endif MOTOROLA // SCI clock 32000000 0x30 // 38462 0x31 // 19230 0x32 // 9615 0x33 // 4807 0x34 // 2403 0x35 // 1201 /* SCI transmitter: XONXOFF control priority byte */ Wireless HC08 Modem AN2262/D Source Code 69 ...

Page 70

... AN2262/D // sending/receiving data BOOL SCI_TxBuff(BYTE* buff, BYTE len); BOOL SCI_TxInPlaceSend(BYTE* buff, BYTE len); BYTE SCI_RxPoll(BYTE* buff, BYTE len); void SciRx_Off(void); void SciRx_On(void); // safe read of SCI received characters count // it is pure read of global variable now since it is single byte operation // and no sync is needed (this may change if app is ported) ...

Page 71

... RF, ...) // global types #define BYTE unsigned char #define WORD unsigned short #define DWORD unsigned long #define BOOL unsigned char MOTOROLA IN NO EVENT SHALL MOTOROLA OR Wireless HC08 Modem AN2262/D Source Code * * * * * * * * * * * * * ...

Page 72

... AN2262/D // macros #define EnaInts() asm cli #define DisInts() asm sei #define FALSE 0 #define TRUE 1 // global symbols defined to specific values required by this // project are in main project header file #include "wem.h" #endif 72 Wireless HC08 Modem MOTOROLA ...

Page 73

... ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * * OF THE POSSIBILITY OF SUCH DAMAGE. * =================================================================== * * * HEADER_END */ #ifndef _TBM_H #define _TBM_H void TBM_Enable(void); void TBM_Disable(void); #endif MOTOROLA IN NO EVENT SHALL MOTOROLA OR Wireless HC08 Modem AN2262/D Source Code * * * * * * * * * * * * * ...

Page 74

... AN2262/D wem.h /********************************************************************** * HEADER_START * * Name: WEM.H * Project: Interconnectivity SRDT * Description: Wireless RS232 demo main header file * This file is included via std.h into all * standard files and sets their control macros * Processor: HC08 * Revision: 1.0 * Date: Feb 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG ...

Page 75

... CONFIG1DEF 0x01; #endif ////////////////////////////////////////////////////// // system flags types typedef struct { unsigned int rfTxActive : 1; unsigned int rfRxActive : 1; #ifdef RF_ECC unsigned int eccNibble : 1; #endif MOTOROLA /* E E COP enabled */ /* COP disabled */ /* RF transmitter just transmitting */ /* RF receiver listen state */ /* TEST */ Wireless HC08 Modem AN2262/D Source Code 75 ...

Page 76

... AN2262/D } SYSFLAGS1; typedef struct { unsigned int sciRxOverflow : 1; /* SCI receiver: buffer overflow */ unsigned int sciRxIdle : 1; unsigned int sciRxIdleS : 1; unsigned int sciRxTmout : 1; unsigned int sciRxTmoutHlpr : 1; (helper bit)*/ #ifdef SCI_XONXOFF_CONTROL unsigned int sciTxPriority : 1; #endif } SYSFLAGS2; ////////////////////////////////////////////////////// // global variables #pragma DATA_SEG SHORT MY_ZEROPAGE extern SYSFLAGS1 sys1; ...

Page 77

... RF stuff // map RF bits into our global flags #define rfTxActive sys1.rfTxActive #define rfRxActive sys1.rfRxActive #ifdef RF_ECC #define eccNibble sys1.eccNibble #endif extern int calc_crc(char *buf, unsigned char n); #endif MOTOROLA // RF transmitter activity // RF receiver activity Wireless HC08 Modem AN2262/D Source Code 77 ...

Page 78

... AN2262/D rf2.c /********************************************************************** * HEADER_START * * Name: RF2.C * Project: Interconnectivity SRDT * Description: Tango2/Romeo2 control * Processor: HC08 * Revision: 1.0 * Date: Feb 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG * Author: Michal Hanak, Pavel Lajsner * Company: Motorola SPS * Security: General Business * * =================================================================== * * Copyright (c): MOTOROLA Inc., 2001, All rights reserved. ...

Page 79

... MOTOROLA /* preamble to be transmitted */ /* header to be transmitted */ /* tail to be transmitted */ 0x07 Wireless HC08 Modem AN2262/D Source Code 79 ...

Page 80

... AN2262/D ////////////////////////////////////////////////////////// // RF initialization // basic init assumed that timers and // other resources are in after-reset state void RF_Init(BYTE* romeoCfg) { RF_RxTimeoutOff(); // disable RX timeout for case we’re in receiving some bytes // transmitter idle rfTxActive = 0; // receiver also idle rfRxActive = 0; StrobeEnable(); RF_RESETB = 1; // needs before entering reset // shut down the transmitter RF_DAT = 0 ...

Page 81

... INLINE void RF_RxTimeoutOn(void) { RFTimerMOD = -1; RFTimerTmoutEnable(); MOTOROLA // Overflow Interrupt disable TIM2 /* clearing RFTimer CH0 flag */ /* RFTimer Channel 0 Interrupt enable */ /* RFTimer Channel 0 Interrupt disable */ /* clearing RFTimer CH1 flag */ /* RFTimer Channel 1 Interrupt enable */ /* RFTimer Channel 1 Interrupt disable */ Wireless HC08 Modem AN2262/D Source Code 81 ...

Page 82

... AN2262/D RF_TimerStart(); } #pragma INLINE void RF_RxTimeoutOff(void) { RFTimerTmoutDisable(); } ////////////////////////////////////////////////////////// // initiate the transmission void RF_TxStart(void) { LedFn1On(); IfBtnJp1BuzzerOn(); // shut down receiver (we don’t want the loopback) // since we share the rx and tx registers RF_RxStop(); // disable RF-related interrupts RF_TxServiceOff(); RF_ManchesterOff(); RF_TimerStop(); // stop the timer RF_TimerReset(); // and reset the timer rfTxActive = 1 ...

Page 83

... RFModeDisable(); // turn off Manchester coding RF_ManchesterOff(); RF_TxServiceOff(); // signal transmitter ready again rfTxActive = 0; // callback the user, he can start another transmission RF_TxFinish_Int(); LedFn1Off(); } MOTOROLA // normal timing for complete message // normal timing for complete message Wireless HC08 Modem // lo CRC byte first AN2262/D Source Code 83 ...

Page 84

... AN2262/D //////////////////////////////////////////////////////////////// // overflow interrupt toggles the data bit to achieve Manchester coding #pragma TRAP_PROC void RFTimerOv_Int(void) { RFTimerCTRL; // ctrl reg. bulk read, needed for correct function of timer RFTimerCTRL_TOF = 0; // just for the case } ///////////////////////////////////////////////////////////////////////////// // output compare interrupt, all tango transmission is done here #pragma TRAP_PROC void RFTimerTxd_Int(void) { #define nextBit BIT(& ...

Page 85

... Manchester coding #pragma TRAP_PROC void RFTimerTmout_Int(void) { RFTimerTMOUT; RFTimerTMOUT_CHF = 0; RF_RxStop(); LedFn2Off(); rfRxLen = rfRxIdx; RF_RxTimeoutOff(); } MOTOROLA /* clearing RFTimer CH1 flag */ /* clearing RFTimer CH0 flag */ // copy the length // and disable this timer Wireless HC08 Modem AN2262/D Source Code 85 ...

Page 86

... AN2262/D ////////////////////////////////////////////////////////// // RF receiver part void DischargeAGC(void) { BYTE i=0xff; // ground AGC capacitors RFDchrgOutputs(); RFDchrgCMixAgcOff(); RFDchrgCAgcOff(); // delay ... ?? while (i--) { asm nop; asm nop enable AGC capacitors again RFDchrgInputs(); } ////////////////////////////////////////////////////////// // enable receiver void RF_RxStart(void get ready to listen DischargeAGC(); // reconfigure SPI (slave, no ints, cpol=0, cpha=1, disabled) SPCR = 0x08; ...

Page 87

... RF_TxChar_Int() to finish transmission #pragma INLINE void RF_TxFinish(void nothing is enough (leaves txBits == get received byte // called from RF_RxChar_Int() #pragma INLINE BYTE RF_RxChar(void) { return rxChar; } MOTOROLA Wireless HC08 Modem AN2262/D Source Code 87 ...

Page 88

... AN2262/D sci.c /********************************************************************** * HEADER_START * * Name: SCI.C * Project: Interconnectivity SRDT * Description: SCI control * Processor: HC08 * Revision: 1.0 * Date: Feb 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG * Author: Michal Hanak * Company: Motorola SPS * Security: General Business * * =================================================================== * * Copyright (c): MOTOROLA Inc., 2001, All rights reserved =================================================================== * * THIS SOFTWARE IS PROVIDED BY MOTOROLA “ ...

Page 89

... SCI_InitTx(BYTE* buff, BYTE size) #endif { #ifndef SCI_FIXED_BUFFS txBuff = buff; txSize = size; #endif txWP = 0; txRP = 0; #ifdef SCI_TXE_CONTROL // turn off the line driver SCI_TXE = SCI_TXE_OFF; #ifdef SCI_TXE_CONTROL_RX // and turn on the receiver SCI_RXE = SCI_TXE_ON; #endif MOTOROLA Wireless HC08 Modem AN2262/D Source Code 89 ...

Page 90

... AN2262/D #endif #ifdef SCI_XONXOFF_CONTROL sciTxPriority = 0; #endif } // copy data to tx buffer, do not call in interrupts (using global i) BOOL SCI_TxBuff(BYTE* buff, BYTE len free space in queue DisTxInt(); i = txRP - txWP; if(txRP <= txWP txSize; // continue with previous chars EnaTxInt(); // space to copy data ? (not that there must always be one BYTE left free) if(len > ...

Page 91

... SCI_TXE = SCI_TXE_ON; #ifdef SCI_TXE_CONTROL_RX // and turn off the receiver (avoid loopback) SCI_RXE = SCI_TXE_OFF; #endif #endif // fetch the char SCDR = txBuff[txRP++]; if(txRP == txSize) txRP = 0; #ifdef SCI_TXE_CONTROL // enable TC interrupt to detect end-of-transmission MOTOROLA Wireless HC08 Modem AN2262/D Source Code 91 ...

Page 92

... AN2262/D EnaTcInt(); #endif } } } ///////////////////////////////////////////////////////////////////////// // receiver // assign RX buffer and it size to SCI receiver #ifdef SCI_FIXED_BUFFS void SCI_InitRx(void) #else void SCI_InitRx(BYTE* buff, BYTE size) #endif { #ifndef SCI_FIXED_BUFFS rxBuff = buff; rxSize = size; #endif rxWP = 0; rxRP = 0; sciRxLen = 0; sciRxOverflow = 0; EnaRxInt(); #ifdef SCI_IDLE_DETECTION EnaRxIdle(); #endif #ifdef SCI_CTS_CONTROL // ready to receive SCI_CTS = SCI_CTS_ON ...

Page 93

... XOFF; EnaTxInt(); #endif // DisRxInt(); } #pragma TRAP_PROC void SciRx_Int(void serve the interrupt _scs1 = SCS1; _rxch = SCDR; // note idle detection is needed, the // only reason for interrupt is SCRF (no need for if) #ifdef SCI_IDLE_DETECTION // SCRF interrupt ? MOTOROLA Wireless HC08 Modem AN2262/D Source Code 93 ...

Page 94

... AN2262/D if(_scs1 & 0x20) #endif { if(sciRxLen < rxSize) { sciRxLen++; // store recvd char and advance pointer rxBuff[rxWP++] = _rxch; // fast modulo if(rxWP == rxSize) rxWP = 0; #ifdef SCI_CTS_CONTROL // signal that buffer is nearly full if(sciRxLen >= rxSize-1) SCI_CTS = SCI_CTS_OFF; #endif #ifdef SCI_XONXOFF_CONTROL if (sciRxLen >= 10/*rxSize-1*/) { sciTxPriority = 1; sciTxPriorityByte = XOFF; ...

Page 95

... DATA_SEG SHORT MY_ZEROPAGE static BYTE div; #pragma DATA_SEG DEFAULT MOTOROLA IN NO EVENT SHALL MOTOROLA OR Wireless HC08 Modem AN2262/D Source Code * * * * * * * * * * ...

Page 96

... AN2262/D ////////////////////////////////////////////////////////// // Timer Base Module interrupt service routine (1 x base) #pragma INLINE void Period_1x(void) { #ifdef SCI_TIMEOUT_DETECTION // SCI timeout sciRxTmout = sciRxTmoutHlpr; sciRxTmoutHlpr = 1; #endif } #pragma INLINE void Period_2x(void #pragma INLINE void Period_4x(void #pragma INLINE void Period_8x(void #pragma INLINE void Period_16x(void #pragma INLINE void Period_32x(void) ...

Page 97

... TBCR_TACK = 1; // TBM int. flag cleared // our internal divider div++; Period_1x(); if(!(div & 0x01)) Period_2x(); if(!(div & 0x03)) Period_4x(); if(!(div & 0x07)) Period_8x(); if(!(div & 0x0F)) Period_16x(); if(!(div & 0x1F)) Period_32x(); if(!(div & 0x3F)) Period_64x(); } MOTOROLA Wireless HC08 Modem AN2262/D Source Code 97 ...

Page 98

... AN2262/D wem.c /********************************************************************** * HEADER_START * * Name: WEM.C * Project: Interconnectivity SRDT * Description: Wireless RS232 demo main file * Processor: HC08 * Revision: 1.0 * Date: Feb 26 2002 * Compiler: HI-CROSS+ Compiler for HC08 V-5.0.11 ICG * Author: Michal Hanak * Company: Motorola SPS * Security: General Business * * =================================================================== * * Copyright (c): MOTOROLA Inc., 2001, All rights reserved. ...

Page 99

... 0x0D 0x2E 0x7F static const BYTE eccDecoder[128 MOTOROLA RF_HEADER, RF_R2CFG_SPEED }; RF_HEADER, RF_R2CFG_SPEED }; Wireless HC08 Modem AN2262/D Source Code 99 ...

Page 100

... AN2262/D 0x0, 0x0, 0x0, 0x3, 0x0, 0xD, 0x6, 0x7, 0x0, 0xD, 0xA, 0xB, 0xD, 0xD, 0xE, 0xD, 0x0, 0x1, 0xA, 0x7, 0x4, 0x7, 0x7, 0x7, 0xA, 0x9, 0xA, 0xA, 0xC, 0xD, 0xA, 0x7, 0x0, 0x3, 0x3, 0x3, 0x4, 0x5, 0xE, 0x3, ...

Page 101

... PBWC_AUTO = 1; /* AUTO on */ while(!(PBWC_LOCK)); /* wait until it locks */ PCTL_BCS = 1; /* & select VCO as a source */ // port pins direction DDRA = I_DDRA; DDRB = I_DDRB; DDRC = I_DDRC; DDRD = I_DDRD; DDRE = I_DDRE; MOTOROLA /* LVI resets disabled, COP ena/disabled */ /* E multiplier multiplier*/ Wireless HC08 Modem AN2262/D Source Code 101 ...

Page 102

... AN2262/D // reset all outputs PTA = 0; PTB = 0; PTC = 0; PTD = 0; PTE = 0; // keyboard INTKBSCR_IMASKK = 1; // mask kbd int PTAPUE = 0xff; // all A pins are pulled up INTKBSCR_ACKK = 1; // clear kbd int bit (just in case) // TBM TBCR_TBR2 = 1; // set TBM period (1024 Hz) TBCR_TBR1 = 0; TBCR_TBR0 = 1; TBCR_TBON = 1; // turn TBM on TBCR_TBIE = 1; // enable TBM int // SCI setup (see wem.h) SCBR = SCI_BAUDRATE ...

Page 103

... SciRx_Off(); MOTOROLA // bump COP (if enabled during compile) // we’ve got some bytes in rfrx buff. + nothing // check rfrx buffer for sanity & remember the // schedule SCI transmission (shall be empty // wrong rfrx buff, restore receive (if not Wireless HC08 Modem AN2262/D Source Code 103 ...

Page 104

... AN2262/D RF_Init(romeoCfgOff); TBM_Disable(); RF_SendBuff(SCI_RxPoll(RF_TxBuff+1, SCI_RxLen())+1); while (rfTxActive) {/* do nothing & wait for data to be transmitted don’t let be disturbed by ANY sci int or another int */}; TBM_Enable(); RF_Init(romeoCfg); SciRx_On(); LedGreenOff(); LedRedOff(); RF_RxStart(); } } } /*-------------------------------------------------------------------------------** ** ** The CRC is based on polynom See also 4. “A Tutorial on CRC Computations” ...

Page 105

... RF interrupt handlers void RF_TxChar_Int(void (rfTxIdx < rfTxLen) #ifdef RF_ECC { if (eccNibble == 0) MOTOROLA // not long enough (min. 4 bytes (LEN // too short len info // too long len info // wrong CRC // return actual data length (minus LEN, minus Wireless HC08 Modem AN2262/D Source Code 105 ...

Page 106

... AN2262/D { eccNibble = 1; RF_TxChar(eccEncoder[(RF_TxBuff[rfTxIdx]>>4) & 0x0F]); } else { eccNibble = 0; RF_TxChar(eccEncoder[RF_TxBuff[rfTxIdx++] & 0x0F]); }; } #else { RF_TxChar(RF_TxBuff[rfTxIdx++]); } #endif else RF_TxFinish(); } void RF_TxFinish_Int(void) { return ; } void RF_RxChar_Int(BYTE ch (rfRxIdx >= RFRXBUFFSIZE) { rfRxLen = rfRxIdx; } else { #ifdef RF_ECC if (eccNibble == 0) { eccNibble = 1; RF_RxBuff[rfRxIdx] = eccDecoder[ch & 0x7f] << 4;// feed the buffer - high nibble } else { eccNibble = 0 ...

Page 107

... AREA_HIRAM = READ_WRITE 0x0100 TO 0x023F; AREA_STACK = NO_INIT PLACEMENT MY_ZEROPAGE INTO AREA_ZPRAM; DEFAULT_RAM INTO AREA_HIRAM; SSTACK INTO AREA_STACK; DEFAULT_ROM, ROM_VAR INTO AREA_FLASH; END MOTOROLA /* Irq1_Int */ /* PLL_Int */ /* Tim1Ch0_Int */ /* Tim1Ch1_Int */ /* Tim1Ov_Int */ /* SpiTx_Int */ /* SciErr_Int */ /* Keyboard_Int */ /* ADC_Int */ 0x8000 TO 0xFDFF; 0x00C0 TO 0x00FF; Wireless HC08 Modem AN2262/D Source Code 107 ...

Page 108

... Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2001 AN2262/D ...

Related keywords