AN07-00200-03E Revision History Date Revision October.24.2008 Revision 1.0: Initial release Revision 1.1:TSUZUKI DENSAN’s Logo mark was changed. May 13, 2009 April 23,2010 Revision 1.2: Change in company name of FUJITSU MICROELECTORONICS [New] FUJITSU SEMICONDUCTOR LIMITED (left blank)
(2) for use requiring extremely high reliability (i.e., submersible repeater and artificial satellite). Please note that Fujitsu will not be liable against you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products.
1.1.2 Installing the integrated development environment SOFTUNE (bits pot yellow dedicated version) ......................22 1.1.3 Installing the PC Writer FUJITSU FLASH USB Programmer (bits pot yellow dedicated version) ........................... 27 1.1.4 Connecting it to the PC and installing the USB driver ..........30 1.1.5 Configuring the starter kit ..................
Page 5
AN07-00200-03E LIN specifications ....................82 5.2.1 Lin frame configuration ..................82 LIN communication flow ..................85 Communication between master and slave if an error occurs ........87 LIN communication by using microcontroller ............. 88 Understanding and overview of the program for LIN communication ......92 5.6.1 LIN communication configuration................
Page 6
AN07-00200-03E List of Figures Figure 1-1 External view of a starter kit ................14 Figure 1-2 System connection diagram (single-unit operation) ..........17 Figure 1-3 System connection diagram (when performing LIN communication) ....18 Figure 1-4 SOFTUNE setup confirmation ................22 Figure 1-5 Starting SOFTUNE setup .................
Page 7
AN07-00200-03E Figure 2-13 Selecting a workspace ..................44 Figure 2-14 Building a project ..................45 Figure 2-15 Completing the build ..................45 Figure 2-16 Load module outputs ..................46 Figure 2-17 Debug settings ....................47 Figure 2-18 Changing the debug settings ................47 Figure 2-19 Starting the debug setting wizard..............
Page 8
AN07-00200-03E Figure 4-10 peripheral circuit diagram for temperature sensor ..........73 Figure 4-11 Single-unit operation flowcharts ..............74 Figure 4-12 Operation mode settings (when using volume switch) ........75 Figure 4-13 Operation mode settings (when using the temperature sensor) ......75 Figure 4-14 Main function program ...................
Page 9
AN07-00200-03E List of Tables Table 1-1 Component list ....................13 Table 1-2 Description of the respective parts of a starter kit ..........15 Table 1-3 MB95F136JBS pin assignment ................19 Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals ....... 62 Table 3-2 LIN communication/Descriptions of the controls and mechanicals ......
AN07-00200-03E Introduction Thank you very much for purchasing the bits pot yellow (referred to as this starter kit or the starter kit hereafter). This starter kit is a beginner’s kit intended for those who wish to start learning microcontrollers and on-board network processors.
AN07-00200-03E Contact Please ask the following e-mail address for the technical question. Please confirm HP for the latest information and FAQ of bits pot. Zip code: 105-8420 2-5-3 Nishi-Shinbashi, Minatoku, Tokyo E-mail: pd-bitspot@tsuzuki-densan.co.jp bits pot URL: http://www.tsuzuki-densan.co.jp/bitspot/...
Table 1-1 Component list Article Qty. Specifications Remarks bits pot yellow Board mounted with microcontrollers made by See Figure 1-1 LIN board Fujitsu Semiconductor; MC-8FX series MB95F136JBS and MC-8LX series MB89P585B USB cable USB (A to miniB) Accessory LIN cable 2-pin cable Accessory...
AN07-00200-03E 14. LIN transceiver IC 13. Regulator 19. Jumper pin 11. USB connector 12. LIN connector 22. LIN transceiver IC Extension power (12V) 20. Extension power 10. Power LED lamp (5V) 21. Extension GND 1. Target device 15. Reset IC 16.
AN07-00200-03E “Table 1-2 Description of the respective parts of a starter kit” provides descriptions of the respective onboard parts. Table 1-2 Description of the respective parts of a starter kit Name Specifications Function Target device MB95F136JBS Main microcontroller (MB95F136JBS). Microcontroller for USB communications to connect USB communication MB89P585B the main microcontroller (MB95F136JBS) and the host...
Page 16
AN07-00200-03E (4MHz) Oscillator for the main microcontroller. Extension pins of the main microcontroller. Extension pins For details, see the circuit diagram. Jumper pin for switching the power supply to the LIN transceiver IC. 1-2 Power supply from USB bus power (5V). Jumper pin (JP1) 2-3 Power supply from external power source (CN5) (12V)
AN07-00200-03E The system configuration during LIN communication operations, which are enabled by connecting the separate bits pot white to “Figure 1-3 System connection diagram (when performing LIN communication)”, which shows the system configuration during single starter kit operations, is shown in “Figure 1-2 System connection diagram (single-unit operation)”. Note: Prepare the PC by yourself.
AN07-00200-03E Note: Prepare the PC by yourself. LIN connector ( accessory ) Figure 1-3 System connection diagram (when performing LIN communication) Connect the PC, the starter kit, and bits pot white using the enclosed USB cables. The power for the bits pot white is also supplied by the USB in the same way as for the starter kit. (USB bus power) [Note] Connect the USB to the PC directly.
AN07-00200-03E “Table 1-3 MB95F136JBS pin assignment” shows the pin assignment for the microcontroller MB95F136JBS. Table 1-3 MB95F136JBS pin assignment Pin No. Function Connected to Remarks LED6 L output = On ‐ ‐ ‐ 4MHz oscillator 4MHz oscillator GND_EARTH ‐ ‐ RESET AVCC AVSS...
Page 20
AN07-00200-03E Use when writing to flash USB-UART conversion P12/UCK0/EC0 or during monitor (MB89P585B) debugging P13/TRG0/ADTG PULL-DOWN P14/PPG0 LED4 L output = On LED5 L output = On...
① Downloading the software ② Installing the integrated development environment SOFTUNE (bits pot dedicated version) ③ Installing the PC Writer FUJITSU FLASH USB Programmer (bits pot yellow dedicated version) ④ Connecting it to the PC and installing the USB driver...
AN07-00200-03E 1.1.1 Downloading the software Download and decompress the file from the following website. bits pot URL: http://www.tsuzuki-densan.co.jp/bitspot/ 1.1.2 Installing the integrated development environment SOFTUNE (bits pot yellow dedicated version) Note If SOFTUNE V3 of the product version has been installed, first uninstall it, and then install the bits pot yellow dedicated version.
AN07-00200-03E The dialog shown in “Figure 1-6 SOFTUNE setup confirmation” will be displayed. Click the “Next” button. Figure 1-6 SOFTUNE setup confirmation The dialog shown in “Figure 1-7 SOFTUNE setup/License agreement” will be displayed. Read the license agreement thoroughly, and then click the “Yes” button. Figure 1-7 SOFTUNE setup/License agreement...
AN07-00200-03E The dialog shown in “Figure 1-8 SOFTUNE setup/Version information” will be displayed. Click the “Next” button. Figure 1-8 SOFTUNE setup/Version information The dialog to select the installation path will be displayed as shown in “Figure 1-9 SOFTUNE setup/Selecting the destination of installation”. select the default folder or desired folder and then click the “Next”...
AN07-00200-03E The dialog to select the components will be displayed as shown in “Figure 1-10 SOFTUNE setup/Selecting the components”. Leaving the default settings as they are, click the “Next” button. Figure 1-10 SOFTUNE setup/Selecting the components The dialog to check the installation settings is displayed as shown in “Figure 1-11 SOFTUNE setup/Confirming the installation settings”.
AN07-00200-03E When the dialog shown in “Figure 1-12 SOFTUNE setup/Completion” appears to tell the completion of installation; Click the “Finish” button. Figure 1-12 SOFTUNE setup/Completion...
AN07-00200-03E 1.1.3 Installing the PC Writer FUJITSU FLASH USB Programmer (bits pot yellow dedicated version) Start Installing the PC writer. Select the following file in the folder you decompressed in “1.1.1 Downloading the software”. ¥ softwares¥ USB PROGRAMMER¥ BGM_MB95F136JBS_setup.exe Double-click “BGM_MB95F136JBS_setup.exe”. The dialog shown in “Figure 1-13 PC writer/Installation dialog”...
AN07-00200-03E The dialog shown in “Figure 1-14 PC Writer/Setup type” will be displayed. Select “complete”, and then click the “Next” button. Figure 1-14 PC Writer/Setup type The dialog shown in “Figure 1-15 Finished PC writer/Ready to install” will be displayed. Click the “Install”...
AN07-00200-03E After the installation complete, the dialog shown in “Figure 1-16 Completing the PC Writer installation” appears to tell the completion of installation; Click “Finish”. Figure 1-16 Completing the PC Writer installation This completes the PC writer installation.
AN07-00200-03E 1.1.4 Connecting it to the PC and installing the USB driver Connect the starter kit to the PC, and install the USB drivers. First, connect the USB port on the PC and the USB port on the starter kit using the enclosed USB cable.
AN07-00200-03E To search for the installation file as shown in “Figure 1-18 Selecting the search locations”, check the “Search for the best driver in these locations” and ”Include this location in the search”. Further, click the “Browse” button, and select the Drivers folder in the SOFTUNE, which has already been installed, and then click the “Next”...
AN07-00200-03E When the driver installation is complete, the dialog shown in “Figure 1-20 Completing the BGM Adapter (MB2146-09) installation” will be displayed. Click the “Finish” button. Figure 1-20 Completing the BGM Adapter (MB2146-09) installation...
AN07-00200-03E 1.1.5 Configuring the starter kit After the USB driver installation is completed, configure the Mode switches on the starter kit, and then connect it to the PC. If the starter kit and the PC are connected by USB (i.e., power is being supplied), disconnect the USB temporarily to turn the power OFF.
AN07-00200-03E After setting the MODE selector, connect the USB port on the PC and the USB port on the starter kit using the USB cable included in the kit. Be sure to connect the PC and starter kit directly, without using a USB hub.
AN07-00200-03E Running the Program To run a program with the starter kit, take either of the following procedures. ① Executing in single chip mode See P.36 ② Debugging by using Monitor Debugger See P.43...
AN07-00200-03E Executing in single chip mode In single chip mode, take the following procedures. ① Building a project ② Writing the program into the microcontroller 2.1.1 Building a project Preparation Decompress the following file in advance within the folder you decompressed in “1.1.1 Downloading the software”.
AN07-00200-03E Click “File” → “Open Workspace” from the SOFTUNE menu as shown in “Figure 2-2 Opening a workspace”. The workspace opens. Figure 2-2 Opening a workspace As shown in “Figure 2-3 Selecting a workspace”, the dialog that allows you to select a workspace is displayed.
AN07-00200-03E As workspace opens, set it as the active project. In this sample program, there are two pre-built projects “single_operation.prj” and “LIN_communication.prj”. Set the project to be built to “Set as Active Project” as projects are built per project basis. In this section, as single-unit operation is described, check that “single_operation”...
AN07-00200-03E Click “Project” → “Build” from the menu as shown in “Figure 2-6 Building a project”, to build the project. Figure 2-6 Building a project The message pane at the bottom of the windows shows the message as shown in “Figure 2-7 Completing the build”...
Turn OFF the starter kit, switch the mode setting to “PROG”, and then turn ON the power supply to the starter kit again. From the Windows start menu, click “All Programs” → “FUJITSU USB PROGRAMMER” → “MB95F136JBS” to activate the PC writer.
AN07-00200-03E The dialog to select the file to which to write will be displayed as shown in “Figure 2-9 Selecting the file to write”, select the file built in “2.1.1 Building a project”, and click “Open”. ¥bitspot_yellow_SampleProgram¥bitspot_yellow_SampleProgram_single-chip¥single_operation ¥Debug¥ABS¥ single_operation.mhx If you built a LIN communication project in “Figure 2-6 Building a project”, select the following file, and click “Open”.
AN07-00200-03E The dialog shown in “Figure 2-11 Completing the program writing” is displayed to notify you that the program writing has been completed. Click the “OK” button to quit the PC writer. Figure 2-11 Completing the program writing Switch the MODE SW on the starter kit to “RUN”, and then press the Reset button; the program starts running.
AN07-00200-03E Debugging by using Monitor Debugger To debug by using Monitor Debugger, take the following procedures. ① Activating SOFTUNE and configuring the debug settings ② Writing the program into the microcontroller (including monitor programs) ③ Loading the target file ④ Running the debugger Activating SOFTUNE and configuring the debug settings 2.2.1 Preparation...
AN07-00200-03E As shown in “Figure 2-13 Selecting a workspace”, the dialog that allows you to select a workspace is displayed. Select the folder containing the sample program for the monitor debugger, and then select the “bitspot_yellow_SampleProgram_monitordebugger.wsp” workspace, and click “Open”. ¥bitspot_yellow_SampleProgram¥bitspot_yellow_SampleProgram_monitor-debugger¥...
AN07-00200-03E Figure 2-14 Building a project The message pane at the bottom of the screen displays the message as shown in “Figure 2-15 Completing the build” to notify you that the build has been completed successfully. Figure 2-15 Completing the build...
AN07-00200-03E Next, configure the load module output settings. As shown in “Figure 2-16 Load module outputs”, select “Project” → “Setup Project” from the menu. The project settings dialog opens, check that “Start load module converter” is enabled on “Converter”. By enabling this checkbox, the load module will be output. Figure 2-16 Load module outputs...
AN07-00200-03E Next, configure the debug settings. On the same project settings dialog, open the “Debug” tab. The debug settings dialog opens as shown in “Figure 2-17 Debug settings”. Figure 2-17 Debug settings Change the category from “General” to “Setup”, and select “mon_dbg” from the setup name list. In the setup name, “mon_dbg”...
AN07-00200-03E The debug setup wizard is displayed as shown in “Figure 2-19 Starting the debug setting wizard” Click the “Next” button. Figure 2-19 Starting the debug setting wizard Select the debugger type as shown in “Figure 2-20 Selecting the debugger type”; select “Monitor Debugger”...
AN07-00200-03E Enter the password as shown in “Figure 2-21 Entering password when starting debugger”. Keep the default settings and then click the “Next” button. Figure 2-21 Entering password when starting debugger Select the device type as shown in “Figure 2-22 Selecting the device type”. Check that “USB” has been selected in the device name, and click the “Next”...
AN07-00200-03E Set the frequency as shown in “Figure 2-23 Setting the primary oscillation frequency”. Set to “D’4” (4MHz frequency setting), and click the “Next” button. Figure 2-23 Setting the primary oscillation frequency Specify nothing to the batch file field as shown in “Figure 2-24 Specifying a batch file”; keep the field left blank and click the “Next”...
AN07-00200-03E Enable the “Auto load when starting debug” checkbox as shown in “Figure 2-25 Configuring the target file settings”, and click the “Next” button. Figure 2-25 Configuring the target file settings Select “Specification” for setup file selection as shown in “Figure 2-26 Setting setup file selection”, and click the “Next”...
AN07-00200-03E When all the settings have been completed as shown in “Figure 2-27 Completing the setup wizard”, click the “Finish” button. Figure 2-27 Completing the setup wizard When the debug settings have been completed, click the “Apply” button and then click the “OK” button as shown in “Figure 2-28 Completing the project settings”...
AN07-00200-03E 2.2.2 Writing the monitor program into the microcontroller Preparation To write programs, it is necessary to set the MODE SW on the starter kit to “PROG” in advance. Turn OFF the starter kit, switch the mode setting to “PROG”, and then turn ON the power supply to the starter kit again.
AN07-00200-03E The dialog to select the file to which to be written is displayed as shown in “Figure 2-30 Selecting the file to write”, so select the file built in “2.2.1 Activating SOFTUNE and configuring the debug settings ”, and click the “Open” button. ¥bitspot_yellow_SampleProgram_monitor-debugger¥single_operation¥Debug¥ABS¥single_operati on.mhx If you built a LIN communication project in “2.2.1 Activating SOFTUNE and configuring the...
AN07-00200-03E Click the “Full Operation” button as shown in “Figure 2-31 Writing the program” to start writing. The program writing begins. Click this. Figure 2-31 Writing the program The dialog shown in “Figure 2-32 Completing the program writing” is displayed to notify you of the completion of the program writing;...
AN07-00200-03E 2.2.3 Loading the target file Click “Debug” → “Start debug” from the menu as shown in “Figure 2-33 Start debugging”. When the debug starts, the target file will be loaded automatically. Figure 2-33 Start debugging Once the monitor program itself is loaded to flash memory, the module can be loaded by the monitor debugger functions subsequently, and, it is not necessary to use the PC writer.
AN07-00200-03E 2.2.4 Running the debugger As shown in “Figure 2-34 Setting break points”, you can set break points to where green round mark is located which is shown on the left side of lines in the source file. .A maximum of only two break points can be set.
AN07-00200-03E Click “Debug” → “Run” → “Go” from the menu, as shown in “Figure 2-35 Running the program”. By this operation, the program runs and the starter kit operates. Figure 2-35 Running the program To stop the program, click “Debug” → “Abort” from the menu as shown in “Figure 2-36 Stopping the program”.
Page 59
AN07-00200-03E 2.2.4.1 If the monitor debugger cannot be controlled It may become unable to control the monitor debugger (I.e., communications between the host system and the target fails.), due to, such as the application program unexpected behavior. In such cases, restart the debugger using the following procedure. ①...
AN07-00200-03E Operation of the sample Programs This section describes the operation of the sample program. The operation of the sample programs is classified into the following two categories. ① bits pot yellow single-unit operation ② LIN communication operation (LIN communication operation with the bits pot white)
AN07-00200-03E bits pot yellow single-unit operation Explanations of the operation and control parts as shown in “Figure 3-1 Single-unit operation/Controls and mechanicals” are described in “Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals”. The LEDs (red) and buzzer are controlled by SW 2, SW 3, volume switch, and temperature sensor on the starter kit.
AN07-00200-03E Table 3-1 Single-unit operation/Descriptions of the controls and mechanicals Name Specifications Function Switches between PROG mode and RUN mode. Mode SW Control PROG: Write a program RUN: Run the program Reset SW Control Resets the MCU when pressed. Turns ON and OFF the LED when pressed. Light up Control LEDs 4 to 6 in order and turn OFF when they are all ON, each time the switch is pressed.
AN07-00200-03E LIN communication operation (LIN communication operation with the bits pot white) Explanations of the operation and control parts as shown in “Table 3-2 LIN communication/Descriptions of the controls and mechanicals” are described in “Figure 3-2 LIN communication operation/Controls and mechanicals”. Perform LIN communication with bits pot white.
AN07-00200-03E Table 3-2 LIN communication/Descriptions of the controls and mechanicals Name Function Description Switches between PROG mode and RUN mode. Mode SW Control PROG: Write a program RUN: Run the program Reset SW Control Resets the MCU when pressed. If SW 2 is pressed when the bits pot white SW4 is set to the left, the value on the LED currently displayed in the starter kit is incremented, and the bits pot white LED and 7SEG Control...
AN07-00200-03E Try to operate the bits pot yellow (single-unit) Overview of single-unit operation After system startup, the starter kit LEDs and buzzers are operated by the switches (SW2, SW3, and volume switch) and temperature sensor as described below. 4.1.1 Turning ON LEDs using switch operations General push switches and LEDs are mounted to the starter kit as shown in “Figure 4-1 Single-unit operation/Switches and LEDs”, and connected to the microcontroller respectively.
AN07-00200-03E input to the INT5 pin changes from High to Low. Further, when SW2 is released, the input to the INT5 pin changes from Low to High. If using the external interrupt function on the microcontroller, an interrupt can be created using timing that changes the pin status. In other words, if using this mechanism, the fact that the switch has been operated can be identified using the interrupt.
Page 68
AN07-00200-03E the rising edge is detected.) (5) Set EIC20 bit 5 to “1”. (This permits INT5 interrupts.)
AN07-00200-03E 4.1.2 Controlling the buzzer using the volume switch This section introduces processing to change the buzzer sound according to changes in the digital signal converted from the analog signals input into the microcontroller. By Volume SW operations, the analog signals input into the microcontroller is converted to digital using an A/D converter and acquire them as digital signals internally.
AN07-00200-03E VCC5 MB95F136JBS 可変抵抗 Variable resistance AN01 (ボリュームSW) (Volume switch) Figure 4-7 Circuit surrounding the voltage adjustment knob In the starter kit, the circuit is configured as shown in “Figure 4-7 Circuit surrounding the voltage adjustment knob”, and adjusting this volume switch changes the value of the voltage applied, and applies this voltage to the pins that perform the A/D conversion.
AN07-00200-03E Next, here explains how to output buzzer sounds. An element called a piezoelectric element is used in the buzzer. Piezoelectric elements are elements that use the piezoelectric effect, and which use materials that create a voltage when shock or pressure are applied (piezoelectricity) or, conversely, which use materials with properties that create a distortion in the crystal configuration when a voltage is applied (reverse piezoelectricity).As shown in “Figure 4-8 Piezoelectricity”, piezoelectric elements have the property of expanding when a...
AN07-00200-03E ++++++++++ ++++++++++ --------------------------- --------------------------- ++++++++++++++++ ++++++++++++++++ 収縮 Contraction ------------------ ------------------ 膨張 Expansion Figure 4-9 Principle of piezoelectric elements In this way, a sound can be created by applying a voltage that changes in AC voltage or pulse voltage to the piezoelectric buzzer. Here, the method outputs a pulse wave using the PPG timer that is built into the microcontroller.
AN07-00200-03E 4.1.3 LED displays using temperature sensor operations This section explains how to display temperature information on the LED using the temperature sensor, which is mounted to the starter kit. A temperature sensor is a sensor for detecting changes in temperature.
AN07-00200-03E Understanding and running the program in single-unit operation This section explains sample programs as programs that practically turn on/of the LED using switch operations and that control the buzzer using the A/D converter operations. Press SW3 Start Press SW2 Initialize Start external interrupt (Port and interrupt levels)
AN07-00200-03E The flowcharts for the sample programs are shown in “Figure 4-11 Single-unit operation flowcharts”. First, the ports, interrupt levels, external interrupts, and A/D converter are initialized. Thereafter, the program enters a loop. Here, when SW2 is pressed, an external interrupt is created, and the LED on/of processing is performed.
AN07-00200-03E As shown in “Figure 4-14 Main function program”, the main functions are around line 165. “Port initialization”, “A/D converter initialization”, and “external interrupt initialization” are contained herein. void main() Port initialization sysInitialize(); AD converter initialization adInitialize(); initial_external_int(); External interrupt initialization __set_il(3);...
AN07-00200-03E Next, an interrupt is created when SW2 is pushed. The external interrupt function _interrupt void Ext_int1_5 in ext_int.c will be called as shown in “Figure 4-15 SW2 interrupts (LED on/off processing)”.Here, the LED display is turned on/off, due to the output settings for the port connected to the LED, or due to the switch being pressed several times, is shown.
AN07-00200-03E The A/D conversion is started in the A/D converter initialization function. Thereafter, when the A/D conversion is finished, an A/D converter interrupt is created as shown in “Figure 4-17 A/D converter interrupts”. Here, the A/D conversion values are acquired from the Volume SW or temperature sensor.
AN07-00200-03E Try to use LIN communication Communication is to send/receive information. There are, in fact, various communications formats, such as transmission by people talking, letters written in script, and electronic communications, etc. Among these, there are various plans for communications using electricity. This chapter explains communications in a standard called LIN.
AN07-00200-03E Seats Rear Power seat and motor control Accessories Rear window heater Passenger detection Wipers Rear wiper Heater Back mirror Rear blinkers Switch control Switch control Doors Motor control ...
AN07-00200-03E The characteristics of LIN used in the way described above, are collated and introduced in the following five points. Single master communication LIN has two types of communication nodes. One is the “master” (sender).This controls the start of all communications. The other is the slave (recipient).The slave responds to commands sent by the master.
AN07-00200-03E to a slave. An ordinary single metal wire is used as the bus cable. CAN combines two opposing metal wires to make one twisted pair cable. FlexRay uses two twisted pair cables. Consequently, LIN has the advantage of using a single cable for numerous network wires, unlike CAN and FlexRay, which use twisted pair cables.
AN07-00200-03E Slave Master Header Identifier Sync byte Break Response Data Check sum Figure 5-3 LIN communication flow Further, headers are configured using three fields: Break, Sync byte, and ID field (Identifier), and responses are configured using two fields: Data field and Checksum field. Header Response DATA1...
Page 84
AN07-00200-03E Break Break, which are in the header fields, are variable-length fields that indicate the start of a new frame. They comprise 13 to 16 “0” bits (fixed value zero) min. The general frame length is 13 bits. Sync Byte Sync byte, which follow on from breaks, are 10-bit fixed-length fields that synchronize the master and the slaves.
AN07-00200-03E LIN communication flow In general LIN communication, one master communicates with numerous slaves. LINs, which adopt a bus topology, connect the master and all the slaves using a single wire, so header electrical signals sent by the master are transmitted by the wire to all the slaves. The slaves check the frame ID, and if the header is addressed to them, sent a response to the master according to the content received.
AN07-00200-03E Master Slave 1 Slave 2 Slave 3 Slave 15 Motor Motor Sensor :Transceiver IC (electronic component for sending and receiving data) Figure 5-5 Main LIN network configuration Master Slave 1 Slave 2 Slave 3 Slave 15 Motor Motor operation operation All communications start from the master...
AN07-00200-03E Communication between master and slave if an error occurs LIN error processing is not determined by the protocols, and so depends on the application. Consequently, during design, it is necessary to consider the error detection methods and the process after the error has been processed.
AN07-00200-03E LIN communication by using microcontroller This section explains practical LIN communication using microcontrollers. In the starter kit, the microcontroller and LIN transceiver IC (TJA1020T) are connected as shown in “Figure 5-7 LIN circuit”.In the microcontroller, SOT sends, SIN receives, and SCK is the port that controls the transceiver IC.
AN07-00200-03E The registers used for entire LIN communication control on the microcontroller are as described in “Figure 5-8 Entire LIN communication control registers”. Registers named “res” cannot be used as they are reserved bits. The description of each register, and the setting values in the sample programs, are described in “Table 5-1 Description of the entire LIN communication control registers and setting values”.
AN07-00200-03E Table 5-1 Description of the entire LIN communication control registers and setting values Register name Set value (contents) Explanation SCR_PEN 0 (no parity) Parity authorization bit SCR_P 0 (even parity) Parity selection bit SCR_SBL 0 (1 bit) Stop bit length selection bit SCR_CL 1 (8 bit) Data length selection bit...
Page 91
AN07-00200-03E ECCR_LBR 0 (LIN synch break not created) LIN synch break creation bit ECCR_MS Serial clock send/receive selection bit ECCR_SCDE Serial clock delay enable bit ECCR_SSM Start / stop bit mode enable bit BGR_BGR1 0x16 (when set to 9600bps) Baud rate generator 1 BGR_BGR0 0x66 (when set to 9600bps) Baud rate generator 0...
AN07-00200-03E Understanding and overview of the program for LIN communication This section explains sample programs as programs that actually perform LIN communication. In bits pot LIN communication, the starter kit operates as a LIN slave, and bits pot white operates as the master.
Page 93
AN07-00200-03E The details of each ID are explained below. ID: 0x00 Temperature measurement byte 0 command A/D value (temperature byte 1 sensor information) byte 2 Reserved byte 3 Reserved byte 4 Reserved byte 5 Reserved byte 6 Reserved byte 7 Reserved Field name Setting value...
Page 94
AN07-00200-03E Field name Set value Remarks This is the starter kit response to the ID 0x00 A/D value temperature measurement command. Temperature (Temperature sensor 0 to 255 sensor information is sent as A/D values, and displayed information) on the bits pot white 7SEG LED. ID: 0x02 Volume value acquire byte 0...
Page 95
AN07-00200-03E ID: 0x03 byte 0 Reserved byte 1 Reserved byte 2 A/D value (VR information) byte 3 Reserved byte 4 Reserved byte 5 Reserved byte 6 Reserved byte 7 Reserved Field name Setting value Remarks This is the response to the ID 0x02 volume value A/D value (VR 0 to 255 measurement command.
Page 96
AN07-00200-03E ID: 0x05 byte 0 Reserved byte 1 Reserved byte 2 Reserved byte 3 LED value byte 4 Reserved byte 5 Reserved byte 6 Reserved byte 7 Reserved Field name Set value Remarks LED value 0 to 7 This is the value of the LED displayed on the starter kit.
AN07-00200-03E 5.6.2 Sample programs sequence The LIN communication flowcharts for the sample programs are shown in “Figure 5-9 LIN communication flowchart (main routine)” and “Figure 5-10 LIN communication flowchart (interrupt routine: UART reception interrupts)”.First, initialize the microcontroller, LIN-UART, and timer. Next, implement LIN bus connection processing as a LIN slave.
AN07-00200-03E The next section explains the sample programs, but the sample programs contain parts in which LIN communication with bits pot white are not used. To make these parts expandable, programs commensurate with LIN use are included. Not all operations, however, are checked. Be careful when using.
AN07-00200-03E ③ ID field reception processing performed LIN-UART interrupt function _LinUART(void).When an interrupt is created, if no error is created and the cause of the interrupt isn’t a synch break interrupt, reception processing is performed. __interrupt void _LinUART (void) (Omitted) Error check if ((ssr &...
Page 104
AN07-00200-03E void l_ifc_rx(l_ifc_handle rx_data){ switch(ucLinStatus){ DATA FIELD send status case LIN_TRANSMIT: (Omitted) DATA FIELD receive status case LIN_DATA_RECEPTION: (Omitted) ID FIELD reception wait status case LIN_ID_RECEPTION: Store received ID ucCurrentId.byte = rx_data; Parity check if( ucCurrentId.fields.parity != ucRightParity[ucCurrentId.fields.id] ) { Error processing (Omitted) If ID received...
AN07-00200-03E ④ DATA field This section explains data sending and reception processing in the data field. First, regarding data sending, if the ID received in the ID field is for a send ID, the vTimeoutCheckTask function is called by the 8/16-bit complex timer (free run timer) interrupt, as shown in “Figure 5-18 Timeout detection processing”.This function is called when the timeout value set using the free run timer is detected, and in this case, is called the detection of the timeout values from the header reception to the response sending (response...
AN07-00200-03E When sending the first data byte, a reception interrupt is created by receiving the self-sent data. Whereupon, the reception judgment processing function _ifc_rx( l_ifc_handle rx_data ) is called in the same way as for ID field operations, and the data is sent from the second byte onwards according to the data field send status as shown in “Figure 5-19 Data send processing”, and the same process is repeated.
AN07-00200-03E The next section explains data reception processing. If the ID acquired using ID reception processing is for reception, the status is migrated to data reception status, and data reception from bits pot white awaited. When a data reception interrupt is created by bits pot white sending data, reception is processed in the reception processing function l_ifc_rx( l_ifc_handle rx_data as shown in “Figure 5-20 Data reception processing”.When data is received as well, reception is processed using l_ifc_rx(data) each time one byte of data is received in...
AN07-00200-03E Finally,about the processes according to the ID received, there is a vBaseTimeTask function around the 100 line of the main routine. This function is called periodically at set cycles, and mainly checks whether or not sending and receiving has finished. If this function is called when all data has finished being sent (i.e., when flagsLinTxRx.bit.SucceedReception has been set), the submain function is called as the reception completion processing as shown in “Figure 5-21 Submain processing”, and temperature measurement processing, buzzer output processing, LED ON...
AN07-00200-03E Appendix Sample program folder/file configuration The folder/file configuration of the sample program is shown in “Table 6-1 Sample program folder/file configuration”. Table 6-1 Sample program folder/file configuration Provision of the file File/folder name Explanation Single Monitor bits_pot_yellow_SampleProgram/bits_pot_yellow_Sampleprogram_singlechip /bits_pot_yellow_Sampleprogram_monitordebugger bitspot_yellow_SampleProgram.wsp Softune workspace file singlechip_operation Folder for Single-unit operation...
Page 110
AN07-00200-03E emu_dbg.sup Emulator debugger file mon_dbg.sup Monitor debugger file include _f2mc8fx.h Microcontroller header definition file define.h Header definition file define_l.h Header file for LIN driver definition extern.h External function reference file fgm.h Header file for incorporated monitor programs lin.h Header file for LIN drivers linapi.h Data communications system API code header file...