<< Previous | Index | Next >> | |
|
If the Rabbit design conventions were followed and Dynamic C cannot establish target communications with the Rabbit 4000-based system, there are a number of initial checks and some diagnostic tests that can help isolate the problem.
11.1 Initial Checks
Perform the first two checks with the /RESET line tied to ground. For the 128-pin LQFP package, the /RESET line is pin 46.
- With a voltmeter check for VDD and Ground (including VBATT ) on the appropriate pins.
- With an oscilloscope check the 32.768 kHz oscillator on CLK32K (pin 49). Make sure that it is oscillating and that the frequency is correct.
- With an oscilloscope check the main system oscillator by observing the signal CLK (pin 2). With the reset held high and no existing program in the flash memory attached to the processor, this signal should have a frequency one eighth of the main crystal or oscillator frequency.
11.2 Diagnostic Tests
The cold boot mode may be used to communicate with the target system without using Dynamic C. As discussed in Section 4.1, in cold boot mode triplets may be received by serial port A or the slave port. To load and run the diagnostic programs, the easiest method is to use the programming cable and a specialized terminal emulator program over asynchronous serial port A. To use the slave port requires more setup than the serial port method and it is not considered here. Since each board design is unique, it is not possible to give a one-size-fits-all solution for diagnosing board problems. However, using the cold boot mode allows a high degree of flexibility. Any sequence of triplets may be sent to the target.
11.2.1 Program to Transmit Diagnostic Tests
The file
SerialIO_1.zip
is available for download at:The zip file contains the specialized terminal emulator program
www.rabbit.com/support/downloads/downloads_prod.shtml/
serialIO.exe
and several diagnostic programs. The diagnostic programs test a variety of functionality, and allow the user to simulate some of the behavior of the Dynamic C download process.
After extracting the files, double click on
serialIO.exe
to display the following screen.Click on Help at the top left-hand side of the screen for directions for using this program.
A diagnostic program is a group of triplets. You can open the provided diagnostic programs (those files with the extension
.diag
) with Dynamic C or any simple text editor if you would like to examine the triplets that are sent to the target. AlsoserialIO.exe
has the option of sending the triplets a line at a time so you can see the triplets in the one-line window next to the Transmit button before they are sent.In the following pages, two diagnostic programs are looked at in some detail. The first one is short and very simple: a toggle of the status line. Information regarding how to check the results of the diagnostic are given. The second diagnostic program checks the processor/RAM interface. This example provides more detail in terms of how the triplets were derived. After reading through these examples, you will be able to write diagnostic programs suited for your unique board design.
11.2.2 Diagnostic Test #1: Toggle the Status Pin
This test toggles the status pin.
- Apply the reset for at least ¼ second and then release the reset. This enables the cold boot mode for asynchronous serial port A if the programming cable is connected to the target's programming connector.
- Send the following sequence of triplets.
- Wait for approximately ¼ second and then repeat starting at step #1.
While the test is running, an oscilloscope can be used to observe the results. The scope can be triggered by the reset line going high. It should be possible to observe the data characters being transmitted on the RXA pin of the processor or the programming connector. The status pin can also be observed at the processor or programming connector. Each byte transmitted has 8 data bits preceded by a start bit which is low and followed by a stop bit which is high (viewed at the processor or programming connector). The data bits are high for 1 and low for 0.
The cold boot mode and the triplets sent are described in Section 4.1 on page 14. Each triplet consists of a 2-byte address and a 1-byte data value. The data value is stored in the address specified. The uppermost bit of the 16-bit address is set to one to specify an internal I/O write. The remaining 15 bits specify the address. If the write is to memory then the uppermost bit must be zero and the write must be to the first 32 KB of the memory space.
The user should see the 9 bytes transmitted at 2400 bps or 416 µs per bit. The status bit will initially toggle fairly rapidly during the transmission of the first triplet because the default setting of the status bit is to go low on the first byte of an opcode fetch. While the triplets are being read, instructions are being executed from the small cold boot program within the microprocessor. The status line will go low after the first triplet has been read. It will go high after the second triplet is read and return to low after the third triplet is read. The status line will stay low until the sequence starts again.
If this test fails to function it may be that the programming connector is connected improperly or the proper pull-up resistors are not installed on the SMODE lines. Other possibilities are that one of the oscillators is not working or is operating at the wrong frequency, or the reset could be failing.
11.2.2.1 Using serialIO.exe
This test is available as
StatusTgl.Diag
, one of the diagnostic samples downloaded inser_io_rab20.zip
.11.2.3 Diagnostic Test #2
The following program checks the processor/RAM interface for an SRAM device connected to /CS1, /OE1, /WE1. The test toggles the first 16 address lines. All of the data lines must be connected to the SRAM and functioning or the program will not execute correctly.
A series of triplets are sent to the Rabbit via one of the bootstrap ports to set up the necessary control registers and write several instructions to RAM. Finally the bootstrap termination code is sent and the program begins executing instructions in RAM starting at address 0x00.
The following steps illustrate one way to create a diagnostic program.
- Write a test program in assembly:
main(){
;
#asm
boot:
ld hl,1
ld b,16
loop:
ld a,(hl)
add hl,hl ; shift left
djnz loop ; 16 steps
jp 0 ; continue test
#endasm
}
- Compile the program using Dynamic C and open the Assembly window. The disassembled code looks like this:
- The opcodes and their data are in the 2nd column of the Assembly window. Since we want each triplet loaded to RAM beginning at address zero, create the following sequence of triplets.
; code to be loaded in SRAM
00 00 21
00 01 01
00 02 00
00 03 06
00 04 10
00 05 7E
00 06 29
00 07 10
00 08 FC
00 09 C3
00 0A 00
00 0B 00
- The code to be loaded in SRAM must be flanked by triplets to configure internal peripherals and a triplet to exit the cold boot upon completion.
The program,
serialIO.exe
, has the ability to automatically increment the address. Instead of typing in all the addresses, you can use some special comments. They are case sensitive and must be at the beginning of the line with no space between the semicolon and the first letter of the special comment.
;Address nnnn
;TripletThe first special comment tells the program to start at address nnnn and increment the address for each transmitted data byte. The second special comment disables the automatic address mode and directs the program to send exactly what is in the file. The triplets shown in #3 may be rewritten as:
;Address 0000
21 01 00 ;ld hl,1
06 10 ;ld b,16
7E ;ld a,hl
29 ;add hl,hl
10 FC ;djnz loop
C3 00 00 ;jp 0
;Triplet
Rabbit 4000 Designer's Handbook |
<< Previous | Index | Next>> | rabbit.com |