Verifying serial buses and components in embedded designs - Embedded.com

Verifying serial buses and components in embedded designs

Embedded systems typically involve a number of serial communications links running between microcontrollers, peripheral chips and the outside world. Before working firmware is completed, designers often need to confirm that a peripheral chip is working as expected. One efficient way to do this is by correlating inputs or outputs with serial bus data being sent between the chip in question and a microcontroller

But verifying that serial buses are in fact working and sending the correct data can be difficult with a simple four-channel digital oscilloscope alone. For applications such as this, it’s vital to have the ability look at both the analog and digital representations of the signal at the same time. This article describes three application examples where signals on peripheral chips were correlated with serial bus data to verify system operation using a mixed signal oscilloscope.

With traditional test and measurement tools it can be difficult to trigger on the event that the engineer is looking for. It can be nearly impossible to tell what information is present by just looking at the analog signal, and it is an extremely time-consuming and error-prone process to have to manually decode bus activity. Mixed signal oscilloscopes equipped with the appropriate triggering and analysis tools offer the necessary decode and search capabilities to verify system operation or to support debug and deeper analysis.

Serial communications controlling a battery charger
The charging of lithium ion batteries is critical. For instance, overcharging can result in damage to the battery and even fire. Lithium ion batteries have protection electronics embedded in the battery pack to monitor cell voltages and temperature as well as current and state of charge. Some versions of the protection electronics provide a means of communicating to the charger or the load to allow access to the information.

Knowledge of battery temperature and individual cell voltages can help prevent over charging or other unsafe conditions. The same information can be used by the load device to indicate to the user when the battery is nearing the point of failure. The most common communications scheme used for this is SMBus, which uses the I2C protocol.

In this example, the charger periodically interrogates the battery temperature (and the cell voltages as well) using the I2 C bus. The challenge is to determine the response of the battery protection electronics and the charger to a new analog temperature input. The charger was specially designed to adjust the charge current to prevent damage to the battery if the battery temperature is below a threshold. To determine if the unit is working properly, the following points should be evaluated:

* Time from a change in temperature to when the data is available via the I2C bus

* Time from when the data is available to when the current starts to adjust

* Time and stability of the current adjustment

* Actual current values before and after the adjustment

Figure 1 below shows the operation of the charger over a period of four seconds to show the response to a temperature change. Information captured included the following:

* The top trace labeled TEMPERATURE shows the sampled analog temperature reading at the battery. The next two analog traces labeled SWITCH_V and “SWITCH_I show the power transistor’s voltage and current respectively, which provide the pulse width modulated control of the charge current.

* The decoded I2C communications bus is monitored by two digital lines labeled DATA and CLOCK shown at the bottom of the screen. The decoded data from the I2C bus labeled I2C is displayed below the current trace.

* The digital signal to the gate of the power transistor marked DRIVE is also captured to allow confirmation of the power control operation.

* In addition, a digital signal marked UPDATE is programmed into the microcontroller to mark when the charger makes a current control correction so that the system response can be measured.


Click on image to enlarge.

Figure 1. Operation of a charger over a period of four seconds.

The setup shown in Figure 1 below up makes it possible to simultaneously monitor the stimulation (Temperature), the communications (I2C), and the effect on the charger switching power supply (Voltage and Current). The technique of inserting an additional monitoring line in the control loop (Update) is also being employed.


Clickon image to enlarge.

Figure 1. Operation of a charger over a period of four seconds.
Using the acquired signal information, the first step was to determine when the change in temperature, which occurs between the positions marked at A1 and A2, is read by the charger. The temperature is read by the battery monitoring electronics during the short pulses on the Temperature trace.

The higher temperature reading is shown at A1 (a thermistor is used so the higher temperature is represented by a lower resistance and corresponding lower voltage). Position A2 is where the lower temperature value is first read. The I2C bus is read at the time of the longer pulse on the Temperature trace; also shown as activity on the Clock and Data digital traces.

Figure 2 below shows the I2 C bus and decode at the sample which occurs after the temperature change is measured by the battery protection electronics. Now the temperature value read after the (0x17) command at C1 has the value of 0x08D4 representing a change in temperature.

This is the first I2C data reading taken after the temperature reading was taken by the battery protection electronics, so the response is as expected. Note that the perspective on the total time frame is maintained in the upper portion of the screen. This magnified display is taken at position C2.


Clickon image to enlarge.

Figure 2: The PC bus and decode at the next sample which occurs after the temperature change is measured by the battery protection electronics. 

Figure 3 below is the same trace greatly magnified to show the detailed current and voltage wave forms during the operation of the switching power supply charge control. A current probe was used to measure the current in the power transistor.

The drive signal is shown correlated to the analog signals so that the drive delay and the switching times can be measured. This data also shows the current ripple measurement which indicated that the power supply inductor ripple was well controlled during the transition from the higher current to the new lower current level.


Clickon image to enlarge.

Figure 3: The same trace is further magnified, showing the detailed current and voltage waveforms during the operation of the switching power supply charge control.
This measurement example showed that the battery protection electronics correctly captured the change in temperature and that the charger was able to read this temperature change and promptly reduce the charge current to respond to the change in temperature. All of the information to measure the time intervals and current response was captured in one trace from which the events in the control system could be evaluated by the engineer as needed.

Short Range data radio Communications
In this example, the mixed signal oscilloscope is used to confirm the correct packet transmission and the timing of each stage of a two-way radio communications system involving a PC communicating to a base station using RS-232 serial communications.

The base station then communicates to a remote unit using a proprietary radio protocol. RS-232 decode capability is used to look at the message sent from the PC to the base station and from the base station to the PC.

The oscilloscope’s analog and digital channels provide insight into the radio transmitted and received signals on both the base station and remote unit. The radio scheme used in this example is AM which allows for very simple circuitry on the remote side. The packet structure consists of eight bytes as follows:

* Header byte = 0x21 for commands (0x28 is used for long data packets not used in this example)

* Two serial number bytes = 0x0000 for the base station and any other value for remotes

* Command byte = 0x30 to 0x3F

* Two argument or data bytes = 0x0000 to 0xFFFF with the low byte first

* Two checksum bytes = the sum of the first 6 bytes with the low byte first

Figure 4 below shows the entire transaction from the RS-232 signal being sent to the base station at E1 to the return message at E2. The RS-232 signals are captured by two digital lines labeled Tx and Rx. The corresponding decoded information is displayed on the lines labeled RS-232(Tx) and RS-232(Rx). The yellow trace labeled BASE_TX_OUT is the analog transmitted signal. The blue trace labeled BASE_RSSI is the base station received analog signal.


Clickon image to enlarge.

Figure 4. Capture showing the full communication cycle from the PC and back.

This signal’s digital version is captured by digital signal labeled BASE_RX_DATA. On the remote side, the purple signal labeled REMOTE_RSSI shows the analog version of the received signal, and the digital signal labeled REMOTE_RX_DATA is the digital version of this signal.

As can be seen from this capture, the entire transaction takes about 230 milliseconds for a full command packet and the return data. Note that the capture is triggered by the start bit of the return RS-232 signal to assure that the entire transaction is captured.

In Figure 5 below the capture is magnified to show the decoded version of the data transmitted from the PC to the base station. With this decode, it is easy to check the data to confirm that the correct packet is being sent, which is true in this case.

Note that the gray zoom window in the upper section of the screen shows the area being displayed in the magnified view. The decoded data shows that the packet is correctly formed with eight bytes. The first byte correctly reflects the command 0x21. Since this is the base station we expect the address to be 0x0000 which it is. The command 0x3A is the request for the battery voltage. Since this is a request, there is no argument so the bytes are zeros. The checksum of 0x5B is the correct sum of the previous bytes.


Clickon image to enlarge.

Figure 5. Decode of the initial RS-232 from the PC.
The next step is to look at the base station transmitted data to ensure that the exact same pattern in both the analog (REMOTE_RSSI) and digital versions (REMOTE_RX_DATA) are being sent and then to evaluate the response from the remote and the length of the delay. In this case it’s only about 5 milliseconds after the receipt of the message from the remote.

In Figure 6 below , the decoded RS-232 message is shown, and can be used to confirm that the return data is what is expected. The decoded data showed that the packet is the proper length of eight bytes. The first byte was again the command header of 0x21.

The address was 0xFFFF which is a legitimate value. The command byte of 0x3A was echoed so that the base station can confirm that the response is due to the command sent and not a misread command. The data value returned was 0x12F which corresponds to 2.5 Volts, which is what was applied. The checksum was the correct sum of the first 6 bytes: 0x21 + 0xFF + 0xFF + 0x3A + 0x2F + 0x01 = 0x0289.


Clickon image to enlarge.

Figure 6. Decode of returned message to the PC.

In this example, the oscilloscope’s RS-232 data decode feature provided a simple way to confirm the correct two-way communication of a radio system. The packets were correctly formed, the header and command values and checksums were correct, and the receiver response time was in the expected range.

Evaluation of SPI-based A/D Converter
In this example, the focus turns to evaluating the performance of a 16-bit A/D converter that communicates using a SPI type serial bus. To create a true differential waveform for the input signal both channels of a two channel signal generator were used.

A mixed signal oscilloscope with the SPI decode capability was used to view the data converted from the incoming signal. The data acquisition hardware consists of a differential input amplifier, an A/D converter, and a microcontroller.

The purpose of this measurement is to check that the A/D converter works correctly as the SPI master, and that it is accurately reading the full input voltage range. The first step was to capture multiple samples in one trace and use the SPI decode capability of the oscilloscope to read the value converted by the A/D. From there, the acquisition was magnified to show samples at different places along the waveform correlated to the decoded digital value produced by the A/D converter.

In Figure 7 below , the yellow and blue traces labeled IN+ and IN- are the voltages from the signal generator. The red trace labeled INPUT_DIFF is the mathematical subtraction of the two input signals and represents the total input to the differential amplifier. The purple trace labeled A/D_IN is the actual input to the A/D converter after the differential amplifier.

These analog traces confirm the correct operation of the analog circuits in front of the A/D. The digital signals labeled CLOCK, DATA, and CONVERT are the SPI control and data signals. The oscilloscope also provided decode of the data on the traces labeled SPI(MOSI) and SPI(MISO).


Clickon image to enlarge.

Figure 7. Multiple acquisitions over a sine wave input.
The trace can be magnified to look at the bottom of the input voltage waveform. Further analysis of the decoded data on the SPI(MOSI) line revealed that the output was 0x00D8, a very low value which was in the expected range . It is also possible to look at a portion of the trace near the top of the input voltage waveform.

In this case, the decoded output value was 0xFCBB, which is close to the top of the 16 bits of A/D range, again as expected. In Figure 8 below, a magnified portion of the trace was taken at a middle point in the input voltage waveform. The decoded output value is 0x7902, which is near the center of the A/D range.


Clickon image to enlarge.

Figure 8. Data taken in the middle of a waveform.

In this example the decoded digital channels were used to confirm that the A/D converter was correctly converting the input voltage over its full range. At the same time, the analog channels were used to confirm that the input amplifier was working as expected. The deep memory of the oscilloscope facilitated this analysis from a single acquisition so additional sample points could be checked to confirm that the digital output values aligned with the analog input at various points.

Summary
Given the popularity of serial communications links between the various microcontroller and the peripheral chips in embedded designs, a mixed signal oscilloscope provides an effective tool to verify that the components and the links are functioning as expected. The specific measurement techniques shown in this article highlighted a few of the ways in which signals on peripheral chips can be correlated with serial bus data.

Gregory Davis is a technical marketing professional at Tektronix and has worked in various aspects of test and measurement over the past 15 years, including product development, outbound marketing, and system-level design and support. Prior to that, he worked in the aerospace industry developing power and monitoring systems for space-based vehicles. He holds a BSET from California Polytechnic University, Pomona, and an MBA from the Drucker/Masatoshi School of Management in Claremont, Ca. .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.