TOOTHPIC RF Solutions, TOOTHPIC Datasheet

MODULE, BLUETOOTH, DATA ACQUISITION

TOOTHPIC

Manufacturer Part Number
TOOTHPIC
Description
MODULE, BLUETOOTH, DATA ACQUISITION
Manufacturer
RF Solutions
Datasheet

Specifications of TOOTHPIC

Svhc
No SVHC (15-Dec-2010)
Summary
Toothpick is a PIC microcontroller and BlueMatik
radio combination, preloaded with Toothpick
Services
interface server, wireless field programming and
Toothpick Slave for optional external host control.
Hardware Features
Ordering Information
Page 1
FlexiPanel
Part No
TOOTHPICK
TOOTHPICK-xxx
FCC / CE / IC certified Class 1 Bluetooth V1.1
128Kbyte Flash, 3.5K RAM, 1K EPROM up to
12 × 10-bit A to D converter
5 × 10-bit PWM outputs
Serial UART, I2C and SPI communications
2 interrupts
20MHz and 32KHz oscillators
Low dropout 400mA power regulator
45 x 22 mm through-hole mount, suitable for
radio, 100m range, integral antenna
512Kbyte I2C external memory
breadboards
9-Apr-06
firmware
Toothpick 3.0.00007
providing
Description
Toothpick 28-pin Dual-in-Line package evaluation version
Toothpick 28-pin Dual-in-Line package – Custom firmware xxx
phone and module not to scale
FlexiPanel
PIC with integral Bluetooth and Toothpick Services firmware layer
DS380-8
user
© FlexiPanel Ltd
Toothpick Services Features
Operating Modes
FlexiPanel server – creates user interfaces on
computers, PDAs, cellphones with no
development needed on remote devices
Wireless field programming lets developers
distribute firmware upgrades electronically
System services including: Bluetooth
communications, interrupt and memory
management, sleep-safe real time clock with
daylight savings time / day-of-week calculator
Pre-tested Firmware Solutions ready for
immediate standalone operation:
Toothpick Slave where Toothpick is controlled
by a host processor via a serial link.
Standalone Toothpick programmable in C for
low-cost, customized standalone operation.
- HappyTerminal
- OpenTooth
- DARC-I
- DARC-II
SDA - SDO - SCL
Patents apply and/or pending
CCP1 - CCP5
control managed via Bluetooth
control with FlexiPanel User Interface
AN0 - AN11
TxD - RxD
INT0 - INT1
Manufactured to ISO9001:2000
Green
TM
TM
Data acquisition and remote
20MHz
Data acquisition and remote
TM
PIC18LF6720
Toothpick
Red
Bluetooth device sensor
TM
TTL Terminal Emulator
32768Hz
Pushbutton
www.FlexiPanel.com
Vdd
LDO 5V reg
Bluematik
Bluetooth
module
400mA
Vin
TM

Related parts for TOOTHPIC

TOOTHPIC Summary of contents

Page 1

... TOOTHPICK Toothpick 28-pin Dual-in-Line package evaluation version TOOTHPICK-xxx Toothpick 28-pin Dual-in-Line package – Custom firmware xxx Page 1 9-Apr-06 Toothpick 3.0.00007 PIC with integral Bluetooth and Toothpick Services firmware layer phone and module not to scale Toothpick Services Features • FlexiPanel user • ...

Page 2

... Glossary and Notation ..............................................................................123 Legal Notices .............................................................................................125 Contact Details ..........................................................................................126 Name Change Notice Toothpick was previously marketed under the name ToothPIC. Since across-the-board name changes including directory names, etc, might introduce errors, references to the old name may appear in this technical documentation and related files. ...

Page 3

... Notes: Ensure the area where the module is mounted has a solid ground plane. To remove the module from an IC socket or breadboard, lever it out using a screwdriver against the pin headers at the sides. Levering from either end may damage components. Page 3 9-Apr-06 Toothpick 3.0.00007 antenna CCP5 RxD CCP3 ...

Page 4

... Vdd may be used as a regulated power output internal regulator is used, total current draw on all outputs (including Vdd if used as a power output) shall not exceed 130mA Page 4 9-Apr-06 Toothpick 3.0.00007 (note 1,2) (note 1,2) DS380-8 © FlexiPanel Ltd Patents apply and/or pending ...

Page 5

... The CE mark on the module indicates that it does not require further R&TTE certification. The exterior of the product should be marked as follows: Page 5 9-Apr-06 Toothpick 3.0.00007 -20ºC to +75 ºC -30ºC to +85 ºC 45mm × 20mm × 10mm excluding pins Class I = 100mW = +20dBm ...

Page 6

... INT1/PGC SDO NMCLR 4K7 Green Vdd The BlueMatik Bluetooth radio is also available separately from FlexiPanel Ltd. For detailed information, consult the BlueMatik technical specification available from www.FlexiPanel.com. Page 6 9-Apr-06 Toothpick 3.0.00007 22pF 22pF 22pF 22pF 32768Hz OSC1 OSC2 RC1 RC0 Vdd ...

Page 7

... Page 7 9-Apr-06 Toothpick 3.0.00007 The Bluetooth radio used in ToothPIC is the same component as used in FlexiPanel Ltd’s BlueMatik and LinkMatik Bluetooth serial bridge modules. Wireless Field Programming a PIC18LF6720 ToothPIC’ ...

Page 8

... I/O pin current drain) when clocked with the 20MHz oscillator and 50µA with the 32kHz oscillator. ToothPIC may be powered with a 5V regulated input to the Vdd pin. Maximum regulated supply voltage is 5.5V. Minimum rated voltage is 4.5V. In practice, ToothPIC will operate effectively down to 3V although Class I Bluetooth performance is not guaranteed ...

Page 9

... Peripheral Components In addition to the main components already detailed, ToothPIC includes: • A 20MHz oscillator main system clock. • A 32768kHz oscillator providing a real time clock and a low power alternate system clock. The BlueMatik radio will not be useable in the low power mode. • Voltage level shifting components between the PIC18LF6720 and BlueMatik powered by I/O pin RB4 ...

Page 10

... Data acquisition and remote control with - FlexiPanel service 2. Use ToothPIC Slave Firmware Solution to allow ToothPIC to be controlled by a host processor. 3. Applications can be developed using C using MPLAB C18 from Microchip Inc. This allows the developer to take advantage of the ToothPIC Services provided by FlexiPanel Ltd. ...

Page 11

... Users should be assumed to be lazy and/or unaware of the need for security: it should be designed into the application. FlexiPanel Ltd provides the ToothPIC Services library exclusively for use with ToothPIC products that it supplies. It will only work with Bluetooth in the BlueMatik components supplied by us ...

Page 12

... ToothPIC303.lib file. If developing using Firmware Solutions, the upgrade will take the form of a service pack as described above, with the following differences: • You will get a message during programming that ToothPIC has reset and is waiting for you to reconnect. Reconnect as specified in step 2 above and press OK. It will take longer than usual for the connection to complete. • ...

Page 13

... Specify the hex file you wish to use for programming in the box labeled Firmware you have external I2C memory connected to ToothPIC and you wish to program it, specify the hex file in the box labeled External Memory. Select 100kHz or 400kHz clock speed as appropriate for the type of memory used ...

Page 14

... See the section Wireless Field Programming Mode in the ToothPIC Services Reference for details on: • How to initiate Wireless Field Programming in ways other than pressing the button down at power-up. • Adding Access Keys for greater security. • Preparing hex files for programming. • Recovery from an interrupted programming cycle. ...

Page 15

... The service packs applications may be executed on Windows and Pocket PC computers as described in the section Using Service Packs. Conventional Device Programming To program ToothPIC using conventional in-circuit programming, pin NMCLR functions as programming pin Vpp, pin INT0 functions as PGD and INT1 functions as PGC. Page 15 9-Apr-06 Toothpick 3 ...

Page 16

... PIN code 0000 if required.) Hello World Bitstream is supplied as a Service Pack application which must be ‘Field Programmed’ into ToothPIC. This takes a few seconds and requires either a Windows Pocket PC with Bluetooth. The procedure is as follows: 1 ...

Page 17

... INT0/PGC INT1/PGD The cable from the debugger to the ToothPIC needs to be short. An adapter cable is available for connecting directly from the ICD2 to a ToothPIC plugged into a breadboard – see the Ordering Information section. The following steps explain how to create the MPLAB project from scratch. You can alternatively load the project HelloWorldBit ...

Page 18

... This will put the radio in slave mode whenever the flag InSlaveMode is not set remote device connects to ToothPIC and then disconnects, ToothPIC will no longer be in slave mode needs to be put back into slave mode again this, a BMTE_Disco message is sent to the BMTEvent callback when the remote device disconnects. At the same time, we will trap the BMTE_Connect message and light the red LED when a remote device is connected ...

Page 19

... BMTRxAdvanceCh processed (or ignored). Second, it clears the software interrupt flag SWI_BMTData. The application should now function correctly. Compile it and load it into ToothPIC. By setting breakpoints in a debugger, you can trap events to see the code being processed. Remember that if you are stopped at a breakpoint, ToothPIC will no longer process information coming from BlueMatik. ...

Page 20

... PIN code 0000 if required.) Hello World FlexiPanel is supplied as a Service Pack application which must be ‘Field Programmed’ into ToothPIC. This takes a few seconds and requires either a Windows Pocket PC with Bluetooth. The procedure is as follows: 1 ...

Page 21

... Download FlexiPanel Designer from www.FlexiPanel.com and start the application the Target Device menu, set the target device to ToothPIC the Insert menu, select Insert Control > Insert Text. You have created a text control. By default it is fixed, meaning the user cannot modify it, and has a maximum of 16 characters. In the properties list box on the right, change the Control Properties > ...

Page 22

... FlexiPanel Clients always read the latest user interface layout information. Change for production to stop FlexiPanel Designer appending a unique number to the end of the Device Name. (It has to do this in order to tell the Clients to reload user interface data.) Page 22 9-Apr-06 Toothpick 3.0.00007 Yes 40 Check it’s at least 51 Center Yes Check it’ ...

Page 23

... HelloWorldRes.h header file and a HelloWorldRes.c source code file which you should save in the project directory. The C code contains the user interface data to be stored in ToothPIC program memory. (You may need to change the #include “ToothPIC.h” path if the file is not in the same directory as your project.) The header file contains computer-generated macros to make it easier to access the controls from your application code ...

Page 24

... The header file contains computer-generated macros to make it easier to access the controls from your application code. 4. Open the file ToothPIC303.c in the development kit main directory and save it in your project directory. This file allows you to customize the ToothPIC Services for this specific application. In this case the only modification required is to change the device name ...

Page 25

... ROM pointer, the second is if the source data is a RAM pointer. The unused argument must be set to zero. The application should now function correctly. Compile it and load it into ToothPIC. By setting breakpoints in a debugger, you can trap events to see the code being processed. Remember that if you are stopped at a breakpoint, ToothPIC will no longer process information coming from BlueMatik ...

Page 26

... Please note that failure to complete these diagnostic tests does not necessarily mean that ToothPIC is not functioning correctly; the fault may lie elsewhere. In particular, take care to verify the COM ports and security settings of the Bluetooth driver on the Windows PC. ...

Page 27

... Then ToothPIC performs a device enquiry for 10 seconds and stores the device names found. Data Transfer ToothPIC then reconnects to the Windows computer. This time the devices are paired so it can connect without asking for the PIN again. First it reports the Bluetooth devices found. Then it measures the transfer time for 100kbits of data first in one direction then the other ...

Page 28

... Executing the Finished Application ToothPIC Diagnostic is supplied as a Service Pack application which must be ‘Field Programmed’ into ToothPIC. This takes a few seconds and requires either a Windows Pocket PC with Bluetooth. The procedure is as follows: 1. Select either the (Windows) or ToothPICTestPPC ...

Page 29

... You can also change the Daylight Savings Time rules and, if the appropriate time is set, watch the date and time advance or retard. (See the Real Time Clock section of the ToothPIC Services Reference for exact details of when the clock changes.) The ...

Page 30

... On some clients, you can click on the chart to zoom it up, see a table of values or save the data to a file. Page 30 9-Apr-06 Toothpick 3.0.00007 If you press Display File, ToothPIC will The second uses ‘overlay’ This is useful for matrix data Press List Section again to On some DS380-8 © ...

Page 31

... User Interface Development in FlexiPanel Designer If you open the file ToothPICTestRes.FxP in FlexiPanel Designer, you will see that this user interface has over 160 controls spread over 15 dialogs. Note how all the dialogs are all in one list and the boundary between dialogs is indicated by the indentation of the control name in the list. A new dialog is created simply by creating the first control in the dialog and then specifying Yes for its New Dialog property ...

Page 32

... Every five seconds, a row of data is appended to the time matrix control. Note how the FxPC_PartUpdate command is used rather than the FxPC_Update command to send the new data to the client. This saves ToothPIC from having to resend the entire matrix – it just sends the new row of data instead. ...

Page 33

... Miscellaneous Ctls: If the image control is clicked, a message is displayed. Note that the password and section controls are handled automatically by ToothPIC Services. Finally message box was created by pressing the ToothPIC button, a FxPE_MsgResp may be generated when one of its response buttons is pressed. The button number is displayed in a number control. ...

Page 34

... DARC-I Firmware Solution The DARC-I Firmware Solution allows ToothPIC to operate as a standalone Data Acquisition and Remote Control (DARC) device controlled by a remote device, using the Bluetooth link, using a simple set of serial commands. No development is required on the ToothPIC. Description DARC example of a Data Acquisition and Remote Control application using ToothPIC. ...

Page 35

... The application code for the ToothPIC DARC-I firmware solution is extensive and the entire project is available for inspection in the development kit. The most important file to note is the application source code file DARC-I.c. The key features of the source code are discussed below. Static Declarations ROM and RAM spaces provided for the user are reserved using static variables such as pFxPRAM000 and p010000 ...

Page 36

... Including and excluding inputs from the sample record set. • Analog to digital conversion. • Deciding where to store the next sample record in memory. • Measuring inputs and storing the result in the sample record array record. Page 36 9-Apr-06 Toothpick 3.0.00007 DS380-8 © FlexiPanel Ltd Patents apply and/or pending www.FlexiPanel.com ...

Page 37

... Bluetooth link. By using FlexiPanel Client software, no development on the remote device is required. Description DARC- example of a Data Acquisition and Remote Control application using ToothPIC. I/O and user interface are configured using FlexiPanel Designer. This configuration is then programmed into DARC-II direct from FlexiPanel Designer using Wireless Field Programming. The I/O pins may be ‘tied’ to controls as follows: • ...

Page 38

... The documentation is of interest in itself because it gives an indication of important elements which should be included in commercial products using DARC-II. In particular, note: • Patents apply and/or pending – all products incorporating ToothPIC are implicitly protected by FlexiPanel’s patents and patent applications. • Field-Programming Instructions – demonstrating this advanced feature of the product which relieves you of the need to manage multiple product lines each with different firmware. • ...

Page 39

... SetBytes( STR_ROM00, (ADD)&DARCcfg.ToFromPin[ID_AN2_D], 0, &cVal, cVal = TFP_NDTM_AN3; SetBytes( STR_ROM00, (ADD)&DARCcfg.ToFromPin[ID_AN3_E], 0, &cVal, cVal = TFP_NDTM_ParallelC; Page 39 9-Apr-06 Toothpick 3.0.00007 // indicates config data has been initialized // output // PWM output // Parallel A and Parallal C are both 3-bits wide // Timebase is 3.2us ( // PWM period is (0xFF + 1) = 256 Timebase units ...

Page 40

... SetBytes( STR_ROM00, (ADD)&DARCcfg.ToFromPin[ID_AN6_16], 0, &cVal, cVal = TFP_BILT_AN7; SetBytes( STR_ROM00, (ADD)&DARCcfg.ToFromPin[ID_AN7_17], 0, &cVal darc data has been programmed, set name and pin code // new name only appears in device discovery after ToothPIC reset if (DARCcfg.Initialized==0x55) { SetBytes( STR_ROM00, (ADD)pLocalName, DARCcfg.ServerName, 0,MAXNAMELENGTHINCZ); SetBytes( STR_ROM00, (ADD)pszPIN, DARCcfg.PINCode, 0, MAXPINLENGTHINCZ ); ...

Page 41

... DARCcfg data structure. Equally, since it will not know in advance what controls exist, it cannot use any macros generated by the FlexiPanel Designer header file. It needs to use the pDevD, pDlgD and pCtlD data structures defined in ToothPIC.h to discover what controls exist. RefreshInputs() The RefreshInputs() function polls the state of the inputs and decides whether any control values need to be changed ...

Page 42

... HappyTerminal Firmware Solution Description HappyTerminal is an example of a commercial application using ToothPIC terminal emulator for monitoring and injecting TTL-level serial data in digital electronic circuits and prototypes. FlexiPanel User Interface Server so that any Bluetooth-equipped Windows PC or Pocket PC can act as the user interface. HappyTerminal features in the September 2005 edition of Circuit Cellar. ...

Page 43

... HappyTerminal transfers the data to the main screen in ASCII mode or Debug mode as appropriate. ErrorStatus No errors are expected. However always possible that ToothPIC will enter an unanticipated state and generate an error. During development best to set a breakpoint so that we can inspect what caused the error. For product release obviously better to enter a failsafe state and/or reset. ...

Page 44

... Configuring the UART based on the values of the controls in the Settings dialog. • Hiding or showing the green Debug mode text controls. • Starting a new line in the main screen. • Transmitting a byte and echoing it if necessary. Page 44 9-Apr-06 Toothpick 3.0.00007 DS380-8 © FlexiPanel Ltd Patents apply and/or pending www.FlexiPanel.com ...

Page 45

... OpenTooth Firmware Solution Description OpenTooth is an example of a commercial application using ToothPIC. OpenTooth detects and recognizes Bluetooth devices within a 10m range, allowing OEMs to add Bluetooth capability to access control products. Typical applications include: • Manual lock release – pulses relay when trusted device present and button pressed. ...

Page 46

... It is possible that a malevolent user might try to connect to OpenTooth in ‘new user’ mode and then try to send data to it. This will generate a SWI_BMTData software interrupt and OpenTooth immediately resets. Page 46 9-Apr-06 Toothpick 3.0.00007 DS380-8 © FlexiPanel Ltd Patents apply and/or pending ...

Page 47

... Controls may be updated while the FlexiPanel server is not operating. This is not a problem in itself but it does generate ERR_NOFLEXIPANELSERVICE warning which needs to be ignored. No other errors are expected. However always possible that ToothPIC will enter an unanticipated state and generate an error. During development best to set a breakpoint so that we can inspect what caused the error ...

Page 48

... ToothPIC Slave is intended for rapid development of ToothPIC applications without the need to be familiar with the MPLAB development environment later date, the complete application can be migrated to the ToothPIC and the host controller is simply omitted from the bill of materials – not even the PCB layout need to be changed. ...

Page 49

... Windows operating system. You will need a Windows PC with a serial port (or USB serial port adapter). 6. The serial outputs of ToothPIC are TTL level and need to be converted to RS232 level. For this, we recommend a MAX233 level converter because all voltage doubling components are integrated into the circuit ...

Page 50

... Note: When sending ASCII commands to ToothPIC, if you make a typing error, avoid pressing delete, or pressing enter repeatedly until an error message is generated. This is because the delete and carriage return characters are legitimate binary characters. Instead, keep tapping a completely illegal character (e.g. ‘ ...

Page 51

... COM Port’ and set the value to the COM port that Bluetooth is using. In FlexiPanel Designer menu, select Target Device > Program ToothPIC Slave from the menu. The user interface will be programmed into the ToothPIC Slave. 18. When programming is complete, ToothPIC Slave will automatically reset and you will see the initialization message again in the HyperTerminal window ...

Page 52

... ToothPIC Services works. The relevant code is in the file Slave.c in the Development Kit. User Interface If you customize the application easiest to program the user interface by setting ToothPIC MPLAB as the Designer target and including the files generated by FlexiPanel Designer in the project in place of SlaveDefaultRes ...

Page 53

... Main Program Loop There is nothing in the main program loop. All the required processing takes place in interrupts. If you want to port your host controller into the ToothPIC, you can do whatever you like here and/or in the callback routines. High Interrupt The high priority interrupt is used to add incoming bytes to the receive buffer ...

Page 54

... Converting from ASCII hexadecimal to binary. • Sending an 0201 (“OK”) response. • Sending DateTime response. • Transmitting IO values responses. • Converting from Control control array index value. Page 54 9-Apr-06 Toothpick 3.0.00007 DS380-8 © FlexiPanel Ltd Patents apply and/or pending www.FlexiPanel.com ...

Page 55

... Then you can start typing a new command. BASIC Stamp Host Setup ToothPIC can be connected directly to BASIC Stamp using any data pins. To send data at 9600 baud to ToothPIC, use the following BASIC command (substitute RxDpin, RTSpin with the actual pins used): ...

Page 56

... Read Memory Write Memory Set Message Reset Command The command byte 0x00 instructs the ToothPIC to reset. Additionally, a command length byte of zero will generate an immediate reset (and will not wait for <CR><LF> ASCII format). Reset Command Examples Reset (binary) Reset (ASCII) ...

Page 57

... Configure ToothPIC Slave Command The command byte 0x01 configures the general properties of the ToothPIC Slave. The byte after the command byte is the Property Byte, which specifies the exact property being set. The remaining bytes represent the new property value, as follows: Configure ToothPIC Slave Command Properties ...

Page 58

... The total queue byte requirement, plus any RAM data used by the FlexiPanel User Interface, must not exceed 0x800 bytes you to check this; ToothPIC cannot do it for you. If Responses Anytime is disabled, 0201 OK responses will not be added to the queue. ...

Page 59

... Get time (ASCII) Configure I/O Command The command byte 0x02 configures the ToothPIC I/O. The byte after the command byte is the Property Byte, which specifies the exact I/O property being set. The remaining bytes represent the new property value, as follows: ...

Page 60

... CCP2 pin as PWM (binary) Set I/O Command The command byte 0x03 sets a ToothPIC I/O output value. The byte after the command byte is the Property Byte, which specifies the exact I/O value being set. The remaining bytes represent the new I/O value, as ...

Page 61

... Set CCP2 as 33% duty cycle (binary) Get I/O Command The command byte 0x04 requests a ToothPIC I/O value. The byte after the command byte is the Property Byte, which specifies the exact I/O value being requested. The value will be read and transmitted as an I/O value response ...

Page 62

... The command byte 0x06 is for the FlexiPanel Server Commands, which are sent directly to the FlexiPanel Server. They control the FlexiPanel User Interface service provided by ToothPIC. The user interface must first be programmed from FlexiPanel Designer as described in the above section Adding a FlexiPanel User Interface ...

Page 63

... User Interface Info Response; control info commands will receive two. Note that since the ToothPIC Slave firmware solution does not know in advance what the user interface looks like, if you ask a meaningless question you may get a meaningless response rather than an error. ...

Page 64

... The data types for the various controls are as follows: Control Data Types Control Page 64 9-Apr-06 Toothpick 3.0.00007 0x0C 0x09 0x0B 0x03 0x00 0x45 0x00 0x00 0x00 0x00 0x00 0x00 0x0C 0x09 0x00 0x03 0x50 0x00 0x00 0x00 0xFF 0x00 0x00 0x00 Data type description ...

Page 65

... No data. No data. 1 byte, 0x00 for off, 0xFF for on. 4 bytes, little-endian, zero-based index of the selected item. Extensive – see ToothPIC Services Reference. No data. 4 bytes, little-endian, signed integer. 1 byte, 0x00 for closed, 0xFF for open. 1 byte, 0x00 for closed, 0xFF for open. ...

Page 66

... The updated row will be immediately transmitted to the client, if connected. Log Row Command Example (X Axis is date-time, 3 columns of 1 byte each) Append ( matrix 0x0002 Page 66 9-Apr-06 Toothpick 3.0.00007 0x0B 0x0B 0x00 0x02 0x06 0x00 0x21 0x00 0x06 0x07 0x08 0x0B 0x0B 0x00 0x02 0x04 0x00 0x16 0x00 0x06 0x07 0x08 ...

Page 67

... The byte after the command byte is the mStr memory storage type as defined in the Memory Management section of the ToothPIC Services Reference. The next two bytes are the Addr memory address (little-endian) as defined in the Memory Management section of the ToothPIC Services Reference. ...

Page 68

... ToothPIC to malfunction. Breakpoint Command The command byte 0x10 instructs the ToothPIC to flash its LEDs, allowing the host to indicate that an error has occurred. It there is no response and no further commands should be sent without resetting the ToothPIC. The byte after the command byte is a FlashVal value. This value is used to control how the LEDs flash. The ...

Page 69

... Get Message Command The command byte 0x40 instructs the ToothPIC to send the next response in the queue, presuming the Responses anytime property is not set. If there are no more responses, the OK response will be sent. Get Message Command Examples Get Message (binary) Get Message (ASCII) Responses Binary responses may bytes long ...

Page 70

... AN3 analog input 0x234 (range 0 to 1023) (ASCII) Parallel A (7-bit) analog input 0x14 (range 0 to 31) (ASCII) Page 70 9-Apr-06 Toothpick 3.0.00007 Interpretation The message queue filled up and some messages were lost The previous command was not understood A FxPE_PingFail ping failure occurred 0x03 0x02 0xF0 “ ...

Page 71

... LinkQ 0x08 Signal 0x09 Low Power 0x10 Receive raw data For more details on any of these responses, consult the BlueMatik Events section of the ToothPIC Services Reference section. BlueMatik Response Examples Device 12:34:56:78:90:AB connected (ASCII) Link quality (Binary) FlexiPanel Server Response The response byte 0x06 reports a response from the FlexiPanel Server. The first byte after the response byte is the Response Value that indicates which response is being reported ...

Page 72

... ToothPIC.h First byte is Control ID; then next 4 bytes are bqFxPDlgData data structure as described in ToothPIC.h First byte is Control ID; then next 4 bytes are bqFxPDlgData data structure as described in ToothPIC.h Data type description. Binary data object – size specified in FlexiPanel Designer. No data. 8-byte DateTimeU data structure. ...

Page 73

... Control Data Response byte 0x09 is a response to a Get Memory Data command. The byte after the command byte is the mStr memory storage type as defined in the Memory Management section of the ToothPIC Services Reference. The next two bytes are the Addr memory address (little-endian) as defined in the Memory Management section of the ToothPIC Services Reference. ...

Page 74

... Page 74 9-Apr-06 Toothpick 3.0.00007 Meaning Set PWM time base to 3.2µs Set PWM period to (0xFF+1) x 3.2µs = 819.2µs (1220Hz) Set CCP1 to PWM output Set duty cycle to 0x01FF x (3.2µ 408.8µs Meaning Set AN0 and AN1 as analog inputs ...

Page 75

... Page 75 9-Apr-06 Toothpick 3.0.00007 Meaning Start FlexiPanel UI Service BlueMatik reports remote device connected. FlexiPanel Service reports FlexiPanel Client connected. Choose Test dialog displayed. (Choose Load Recommended Layout from menu if layout unusual.) Show dialog 0x01 (Test Real Time Clock) End test button (ID = 0x0109) pressed End FlexiPanel service ...

Page 76

... Use the Hello World example if none of the others are appropriate. Make sure you can successfully compile the source code and load it into ToothPIC before proceeding to step 2. If you prefer to start a new project rather than working from a firmware solution, be sure to specify: • ...

Page 77

... ErrorStatus(), the Services error callback BMEvent(), the BlueMatik callback FxPEvent(), the FlexiPanel UI callback 5. ToothPIC Programming ToothPIC is programmed with the executable code, either using the Wireless Field Programmer or using MPLAB with a conventional in-circuit programming device such as the ICD-2 debugger. Once the developer function main() begins, ...

Page 78

... Both the client and the BASIC Stamp can modify the user interface controls at any time. The client or ToothPIC may choose to disconnect. Additionally, the link may be dropped if the devices go out of range of each other. The state of the ...

Page 79

... In this release of FlexiPanel, the only use of the blob object is to pass the name of a URL (i.e. web page address) to the client. Files Control The files control allows ToothPIC to send files to the Client. The primary use of this feature is to pass browser on the client could display the files. Since the files are stored on ToothPIC, an internet connection is not required ...

Page 80

... ToothPIC Services are pre-installed in the protected memory region 0x0000 to 0xBFFF and are not available if you choose to overwrite this memory. Certain functions are more suited to inline compilation and are macros defined in the file ToothPIC.h. Examples of the use of most services can be seen in the BlueMatik Diagnostic and ToothPIC Diagnostic Firmware Solutions. Analog I/O ToothPIC’ ...

Page 81

... Turns BlueMatik off. In addition call ClearSemaphores to reset the state of the ToothPIC services with respect to BlueMatik Turns BlueMatik on. In addition call ClearSemaphores to reset the state of the ToothPIC services with respect to BlueMatik pauses until the previous BlueMatik command is complete pauses until BlueMatik connection is complete or TO units of 100ms have ...

Page 82

... AwaitBMTOK; BMTCommand( BMTC_Security, 0, Sec_AuthEncr ); AwaitBMTOK; // Set hold parameters (max, min, hex units of 0.625ms) BMTCommand( BMTC_General, 0, (rom void *)"AT+BSHP=200,80\r" ); Page 82 9-Apr-06 Toothpick 3.0.00007 DS380-8 © FlexiPanel Ltd Patents apply and/or pending *pData (or *pDataR if pData is null pointer) inquiry duration in seconds as ASCII hexadecimal (zero terminated ...

Page 83

... Semaphores section for this exact example. Don’t send any data to BlueMatik until you get confirmation that the connection was successful using AwaitBMTConnect and ConnectSuccess. ToothPIC also uses the term ‘slave mode’ different sense, where theToothPIC module is controlled by a host processor which via a conventional TTL serial connection. The firmware solution always referred to by its full name, ‘ ...

Page 84

... By default, ToothPIC can remember paired devices. The 25th paired device erases the 1st, etc. Once a paired device has been erased, it will need to re-authenticate. The section ToothPIC Settings and Link Key Map describes how to change the number of paired devices that ToothPIC stores limit of 255 devices. ...

Page 85

... EventID==BMTE_LinkQ ) uch = *(unsigned char *) pData1; } Notes: BMTEvent may be called at any time, so care should be taken if modifying static values other than semaphores which are also used by your main code. Page 85 9-Apr-06 Toothpick 3.0.00007 *pData1 Not used Error code (unsigned char) Warning code (unsigned char) Remote device Bluetooth ID ...

Page 86

... Page 86 9-Apr-06 Toothpick 3.0.00007 Meaning RTC (Ready to communicate) RTR (Ready to receive) IC (Incoming call) DV (Data valid) FC (Flow control) Meaning Remaining *pData2 fields are valid Length of break signal in units of 200ms Error description General error – see note below Connection attempt while module not idle Operation can’ ...

Page 87

... Note in particular that if a remote device disconnects while ToothPIC is trying to send it data, a general error be generated. The correct response to this is to perform a BMTC_Reset command to return BlueMatik to a known state. See any of the firmware solutions for an example of how this is done ...

Page 88

... BMTTxWaitBytes(1); *BMTTxCh = 'A'; BMTTxAdvanceCh; char i; BMTTxWaitBytes(26); for ( i=0; i<26; i++ ) *BMTTxLoc( Whole alphabet BMTTxAdvance(26 ToothPIC 3.0.00005, BMTTxLoc and BMTTxCh have not been fully implemented and the BMTTransmit macro should be used instead. Page 88 9-Apr-06 Toothpick 3.0.00007 // Wait for space // Put character in buffer // Transmit DS380-8 © ...

Page 89

... The BMTTxWaitBytes(i) macro waits until there is space in the transmit buffer to add i characters. It can be called before BMTTxAdvance to avoid buffer overrun. i must be of type unsigned char – this is a macro and no type casting is done ToothPIC 3.0.00005, BMTTxWaitBytes has not been fully implemented and the BMTTransmit macro only should be used. BMTReceive Bool BMTReceive( BMTReceive service takes nBytes of serial data from the receive buffer and places them in pRxData ...

Page 90

... Bluetooth Device Classes The 3-byte Bluetooth device class, specified in the ToothPIC Settings and Link Key Map as the variable DeviceClass, determines what the module claims to be when other Bluetooth devices ask it. It affects the icon that appears on other Bluetooth devices and may affect the device discovery function. In particular some mobile phones only look for certain sub classes, e ...

Page 91

... Resulting bytes (bitwise OR together the above) Byte A 0x92 1001 0010 Minor device class The last byte defines the minor device class. Its interpretation depends on the major device class specified as follows. (ToothPIC.h provides definitions for these values.) Byte C Computer Major Class 0x00 ...

Page 92

... Keyboard and pointing device † Callbacks When events occur that ToothPIC wants to tell you about, it calls a callback function. Callbacks are functions which you must provide, even if you do nothing in them. The “Hello World” Firmware Solutions show the minimum your application needs terms of callback functions. ...

Page 93

... The PIC18LF6720’s Dual Analog Comparators are available for developer use on certain ANx pins. The following macros are provided in ToothPIC.h: Macro CmpsOff CmpsBuffer CmpsInvert SetCmpsIntOnChange (iPriority) Configuration Settings ToothPIC assumes the following configuration settings on the PIC18LF6720: • HS oscillator configuration • Watchdog timer off • Watchdog timer postscaler 1:128 • Power-up timer on • ...

Page 94

... ToothPIC only trigger under certain conditions. If the ToothPIC Services library is used with Bluetooth components that are not supplied by us, it may work initially but ‘self destruct’ later date. Use of such features minimizes costs to our legitimate customers. ...

Page 95

... PC3 3 CCP5,CCP4,RxD PC2 2 CCP5,CCP4 To set or read the I/O direction, set the direction setting function as appropriate using the constants DirParInput and DirParOutput. For example: DirPA7( DirParInput ); Page 95 9-Apr-06 Toothpick 3.0.00007 Value storing variable AN10Pin AN11Pin CCP1Pin CCP2Pin CCP3Pin CCP4Pin CCP5Pin INT0Pin INT1Pin ...

Page 96

... FxPC_PartUpdate (06) FxPC_SetProps (07) FxPC_InitData (09) FxPC_MultiUpdate (0A) FxPC_MultiPartUpdate (0B) Page 96 9-Apr-06 Toothpick 3.0.00007 // Set up PC4 digital output // if AN1 is 0, AN2 is 1, AN3 e.g. binary 011 = 0x03 // set AN8 to 1, AN9 to 0, AN10 to 0, AN11 e.g. binary 1001 = 0x09 Command description Starts FlexiPanel server Selects a new dialog to display ...

Page 97

... BMTE_Connect when any remote device connects and with FxPE_Connect when the remote device identifies itself as a FlexiPanel client. FxPC_SetDialog: FlexiPanel Designer permits multiple dialogs to be defined for ToothPIC using the New Dialog control property. FxPC_SetDialog selects the dialog that is displayed. The dialog index numbers start at zero ...

Page 98

... FlexiPanel Protocol. If the client device is version 2, a full update will automatically be sent instead. The following example shows FxPC_PartUpdate used for data logging to a matrix. Page 98 9-Apr-06 Toothpick 3.0.00007 pRULong must be rom pointer to 4-byte signed FxPCommand( FxPC_CtlUpdate, ID_List5_5 DS380-8 © FlexiPanel Ltd Patents apply and/or pending www ...

Page 99

... FxPC_MultiPropsUpdate: Allows multiple control partial updates to be sent to the client in a single message. This ensures they all appear to update at the same time also more efficient in terms of bytes Page 99 9-Apr-06 Toothpick 3.0.00007 // Clear interrupt flag DS380-8 © FlexiPanel Ltd Patents apply and/or pending ...

Page 100

... BSR PROD, MATH_DATA FxPE_Connect: Event is generated after connecting device has been verified as a FlexiPanel compatible device but before any messages are sent to it. Page 100 9-Apr-06 Toothpick 3.0.00007 Event description FlexiPanel client connected FlexiPanel acknowledge message Client updated a control FlexiPanel client ...

Page 101

... Request Acknowledge in FlexiPanel Designer. FxPE_Disco: Event is generated after a verified FlexiPanel compatible device is electing to disconnect. If the disconnect is at ToothPIC’s request (through the FxPC_Finish command), this message will not be received. In either case, a BMTE_Disco event will be generated and then BlueMatik is placed into slave mode again ready for another FlexiPanel device to connect ...

Page 102

... ToothPIC software version number is written to pVersionStr. • If initialization was due to a power-on reset, the RealTimeClock value is set to the value RESETTIME specified in the ToothPIC settings and link key map. Similarly the DSTEvent variable is set to the value DSTDEFAULT. • If the ToothPICSettings flag BQS_RealTimeClock is set, the real time clock is started. (This is the last instruction executed before passing control to c018itp.c.) • ...

Page 103

... Note that the clock time is not changed if initialization is due to a software reset, so the module can use the software reset to return to a known state without the real time clock being re-initialized. If the button was pressed at power-up, ToothPIC will enter wireless field programming mode. If not, control then passes to c018itp.c, which initializes C static variables and reinitializes the stack. ...

Page 104

... The SWI_Tick interrupt may miss beats if other low priority interrupts take longer than a second to process. The RealTimeClock clock values will, however, remain correct since these are incremented in a high priority interrupt by the ToothPIC Services. The following variables and macros are defined in ToothPIC.h and/or ToothPIC303.c: Definition SWIflags ...

Page 105

... The I2C Synchronous Serial I/O is available for developer use on the SDA and SCL pins. The Hardware Peripheral Library provided with C18 provides I2C functions. Page 105 9-Apr-06 Toothpick 3.0.00007 Set high and low priority interrupts (default) Enable high priority interrupts Enable low priority interrupts (see caution above) ...

Page 106

... PIC18LF6720 documentation to use this feature. Memory Managment Overview ToothPIC provides functions for reading and writing data to RAM, ROM, EE and External memory. A storage type flag specifies which type of memory written to or read. GetBytes The service GetBytes retrieves nBytes bytes of data from memory mStr at address Addr and places them ...

Page 107

... Other RAM locations are not accessible using the memory manager. STR_ROM: Internal ROM locations 0x000000 to 0x00BFFF are not accessible to prevent overwriting of the ToothPIC OS. A write may take a few milliseconds as described in Microchip Technology’s documentation. During this time, interrupts are turned off and communication with BlueMatik is automatically suspended. Any other services which require a fast response (such as asynchronous serial I/O) should be suspended during a write operation to ROM ...

Page 108

... ERR_MEMORYFAILURE. (If SDA or SCL are incorrectly configured or lack pullup resistors, GetBytes and SetBytes may never return or call ErrorStatus.) Memory Map and Linker Scripts The linker script ToothPIC303.lkr tells the linker how to allocate ROM and RAM memory. The RAM memory is arranged as follows: RAM location ...

Page 109

... Large code model (>64Kbytes) • Large data model (all RAM banks) • Multi-bank stack model Operation Without BlueMatik Installed The BlueMatik module is designed to be removable so that, to reduce cost, it may be detached from ToothPIC after programming. If ToothPIC initializes without a BlueMatik module attached, semaphore BKSF_BMTEXISTS will be clear. ...

Page 110

... If communication does resume, it may continue right up to the end of the sniff interval. However, if resumed communication ceases at any time for longer than T stay ceased until the start of the next sniff interval. Page 110 9-Apr-06 Toothpick 3.0.00007 // Enter low speed mode msDelay high speed, wait 1ms Turns BlueMatik off (cannot receive) ...

Page 111

... Library provided with C18 provides PWM functions. Real Time Clock If BQS_RealTimeClock is set in the ToothPICSettings flags, timer 1 is initialized for use as a real time clock. The developer may override this setting by clearing this flag. This will have the following effects: • The real time clock will not advance. ...

Page 112

... The BQS_ClientTick flag may be cleared if the developer wishes to arrange to update the client less frequently. A utility exists in ToothPIC.h to automatically calculate the day of the week given the date, month and year. This is detailed in the Utility Services section. Daylight Savings Time adjustments are implemented. Daylight Savings Time rules vary from region to region. ...

Page 113

... DST_W_EUROPE_SUMMER Reset State The following macros are defined to help you determine what caused the last reset. If none are true, the last reset was a hardware reset applied to the NMCLR pin. ResetOrWakeEventWasPowerOn Page 113 9-Apr-06 Toothpick 3.0.00007 Month Date Day of week 2 15 Sunday ...

Page 114

... In addition to your own semaphores, ToothPIC OS provides certain semaphores which it uses to communicate the current state of the ToothPIC OS. You may inspect these logical values but you should not modify them except by calling ClearSemaphores in when initializing BlueMatik. The semaphores and macros are defined in ToothPIC ...

Page 115

... Other baud rates may be obtained by consulting Microchip Technology documentation. Examples of the use of these macros is given in the HappyTerminal and ToothPIC Slave Firmware Solutions. SPI Synchronous Serial I/O The PIC18LF6720’s SPI Synchronous Serial I/O is available for developer use on the SDO, SDA and SCL pins ...

Page 116

... ToothPIC Settings and Link Key Map The file ToothPIC303.c defines shared areas of ToothPIC’s memory known as the ToothPIC Settings and Link Key Map. In this area you can customize the ToothPIC Services. Definitions for this area of memory appear in ToothPIC303.c after the line: ...

Page 117

... Bear in mind some devices (phones) can only enter PIN codes with digits 0-9. To disable authentication, use the BMTC_Security command– do not set the PIN to zero length. This is because a remote device may require a PIN even if ToothPIC doesn’t. The default PIN code is the Bluetooth de facto default value, 0000. ...

Page 118

... Works correctly even at 8192IPs clock speed. Example: msDelay Page 118 9-Apr-06 Toothpick 3.0.00007 // report the value of ReceivedByte // (4+1)* cycle delay or 16us // 10ms delay DS380-8 © FlexiPanel Ltd Patents apply and/or pending ...

Page 119

... Whichever outcome, ToothPIC will then reset. To provide security, an access key is specified as the string pszWFPAccessKey in the ToothPIC settings and link key map. If this is not a null string, ToothPIC will require the Wireless Field Programmer to provide the same access key before it will be permitted to reprogram it. pszWFPAccessKey is the word “Access” by default ...

Page 120

... This unlikely unless power is lost or one of the devices goes out of range. Recovery is possible by re-entering WFP mode using Hard-WFP and reprogramming. By default, the access key is not required for Hard-WFP. It can be enabled by specifying the ToothPIC setting BKS_AccessKeyOnHardProgram. This may, however, make it difficult to re-enter WFP after a corrupt programming cycle and wired programming may be the only option ...

Page 121

... In the OpenTooth subdirectory, the documentation OpenTooth.pdf, service packs and source code files for the OpenTooth Firmware Solution. 11. In the ToothPIC Slave subdirectory, service packs and source code files for the ToothPIC Slave Firmware Solution. 12. In the HTerm subdirectory, service packs and source code files for the HappyTerminal Firmware Solution ...

Page 122

... HappyTerminal firmware solution added WFP made secure against accidental programming – upgrade to V3.0.00005 required to use WFP ToothPIC Slave ANx pin input response too long - corrected BMTC_Reset command added Libraries updated for Microchip C18 compiler v3.01 Toothpick Slave/Stamp Edition PIN code & Device name error ...

Page 123

... Buffer – A linear region of memory designed for storing data entering from or departing to a communications channel. Page 123 9-Apr-06 Toothpick 3.0.00007 Circular buffer – A ‘first-in-first-out’ buffer which wraps around. when the next byte dispatched (i.e. read or transmitted) and an end pointer indicating the last piece of data to be dispatched. The start pointer advances when its data is dispatched ...

Page 124

... Unicode character set. User – The person using the finished product (as opposed to the Developer). Zero Terminator – A zero-valued character used to indicate the end of a string of characters. Page 124 9-Apr-06 Toothpick 3.0.00007 In FlexiPanel 3.0 DS380-8 © FlexiPanel Ltd Patents apply and/or pending www.FlexiPanel.com ...

Page 125

... FlexiPanel Ltd reserves the right to make changes to its technology and documentation in order to improve reliability, function or design. Software Libraries FlexiPanel Ltd provides software such as the ToothPIC Services exclusively for use with products made by FlexiPanel Ltd. permitted to use the libraries except with products made by FlexiPanel Ltd not permitted to ...

Page 126

... Tel: +44 (0)1273 898 000 Fax: +44 (0)1273 480 661 Technical Information and Customization Contact Details ToothPIC is owned and designed by FlexiPanel Ltd. For technical support, contact FlexiPanel Ltd: FlexiPanel Ltd Suite 120, Westbourne Studios 242 Acklam Road London W10 5JJ, United Kingdom www ...

Related keywords