Am trying to debug a program using msp430-gdbproxy and a JTAG and am unable
to get past a continuous loop where the program waits for the oscillator to
settle.  This is very frustrating as that part of the program actually works
(when not debugging) and really want to investigate the rest of the program.

To steps being followed are:
- start msp430-gdbproxy-debug
- start msp430-gdb, 
  - connect to msp430-gdbproxy, 
  - load the program, 
  - set a breakpoint in the program, well past where the oscillator is
initialised.
  - continue.

gdbproxy then continuously reports timeout errors:
...
debug:     msp430: msp430_wait_partial()
debug:     msp430-gdbproxy.exe: timeout while reading from GDB
debug:     msp430: msp430_wait_partial()
debug:     msp430-gdbproxy.exe: timeout while reading from GDB
debug:     msp430: msp430_wait_partial()
debug:     msp430-gdbproxy.exe: timeout while reading from GDB
...

Breaking into the program and using gdb commands it looks like the program
is stuck in the following loop:
...
474       do                                             // wait in loop
until crystal is stable
475         IFG1 &= ~OFIFG;
476       while (IFG1 & OFIFG);
...

Which has the assembler of:
...
0x00001d00 <InitOsc+16>:        bic.b   #2,     &0x0002 ;r3 As==10
0x00001d04 <InitOsc+20>:        bit.b   #2,     &0x0002 ;r3 As==10
0x00001d08 <InitOsc+24>:        jnz     $-8             ;abs 0x1d00
...

Am really open to suggestions of what to do here.  How do other programs get
debugged (presuming that they also have to set the oscillator?).

A log of a sample session (including more source code) is given below if
that is going to be of any help.

Thanks for any help or comments,
aLUNZ

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** Start up gdb, set a breakpoint and continue the program

C:\Projects\EasyWeb2>msp430-gdb -command=gdb-target.ini easyweb2.elf
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-cygwin --target=msp430"...
0x00001100 in _reset_vector__ ()
Erasing target flash - all... Erased OK
Loading section .text, size 0x3216 lma 0x1100
Loading section .data, size 0x2 lma 0x4316
Loading section .vectors, size 0x20 lma 0xffe0
Start address 0x1100, load size 12856
Transfer rate: 4674 bits/sec, 357 bytes/write.
(gdb) b easyweb.c:106
Breakpoint 1 at 0x178c: file easyweb.c, line 106.
(gdb) info breakpoints
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x0000178c in main at easyweb.c:106
(gdb) c
Continuing.

*** After this msp430-gdbproxy-debug continuously reports timeout errors. So
*** pressing Ctrl-C, then step through the program to try and figure out
what
*** is going on:

Program received signal SIGINT, Interrupt.
InitOsc () at easyweb.c:475
475         IFG1 &= ~OFIFG;
(gdb) where
#0  InitOsc () at easyweb.c:475
#1  0x00001d00 in InitOsc () at easyweb.c:472
(gdb) l
472       _BIC_SR(OSCOFF);                               // turn on XT1
oscillator
473
474       do                                             // wait in loop
until crystal is stable
475         IFG1 &= ~OFIFG;
476       while (IFG1 & OFIFG);
477
478       BCSCTL1 |= DIVA0;                              // ACLK = XT1 / 2
479       BCSCTL1 &= ~DIVA1;
480
481       IE1 &= ~WDTIE;                                 // disable WDT int.
(gdb) stepi
0x00001d04      475         IFG1 &= ~OFIFG;
(gdb) stepi
0x00001d08      475         IFG1 &= ~OFIFG;
(gdb) stepi
475         IFG1 &= ~OFIFG;
(gdb) stepi
0x00001d04      475         IFG1 &= ~OFIFG;
(gdb) stepi
0x00001d08      475         IFG1 &= ~OFIFG;
(gdb) stepi
475         IFG1 &= ~OFIFG;

*** And this is the loop that the program seems to be stuck in.  To help
*** put this in context, get some listings (in both C source and 
*** disassembler):

(gdb) disassemble InitOsc
Dump of assembler code for function InitOsc:
0x00001cf0 <InitOsc+0>: mov     #23168, &0x0120 ;#0x5a80
0x00001cf6 <InitOsc+6>: bis.b   #64,    &0x0057 ;#0x0040
0x00001cfc <InitOsc+12>:        bic     #32,    r2      ;#0x0020
0x00001d00 <InitOsc+16>:        bic.b   #2,     &0x0002 ;r3 As==10
0x00001d04 <InitOsc+20>:        bit.b   #2,     &0x0002 ;r3 As==10
0x00001d08 <InitOsc+24>:        jnz     $-8             ;abs 0x1d00
0x00001d0a <InitOsc+26>:        bis.b   #16,    &0x0057 ;#0x0010
0x00001d10 <InitOsc+32>:        and.b   #-33,   &0x0057 ;#0xffdf
0x00001d16 <InitOsc+38>:        bic.b   #1,     &0x0000 ;r3 As==01
0x00001d1a <InitOsc+42>:        bic.b   #1,     &0x0002 ;r3 As==01
0x00001d1e <InitOsc+46>:        mov     #23070, &0x0120 ;#0x5a1e
0x00001d24 <InitOsc+52>:        bit.b   #1,     &0x0002 ;r3 As==01
0x00001d28 <InitOsc+56>:        jz      $-4             ;abs 0x1d24
0x00001d2a <InitOsc+58>:        bic.b   #2,     &0x0002 ;r3 As==10
0x00001d2e <InitOsc+62>:        bis.b   #-64,   &0x0058 ;#0xffc0
0x00001d34 <InitOsc+68>:        ret
End of assembler dump.

(gdb) list easyweb.c:467, easyweb.c:492
467     void InitOsc(void)
468     {
469       WDTCTL = WDTPW | WDTHOLD;                      // stop watchdog
timer
470
471       BCSCTL1 |= XTS;                                // XT1 as
high-frequency
472       _BIC_SR(OSCOFF);                               // turn on XT1
oscillator
473
474       do                                             // wait in loop
until crystal is stable
475         IFG1 &= ~OFIFG;
476       while (IFG1 & OFIFG);
477
478       BCSCTL1 |= DIVA0;                              // ACLK = XT1 / 2
479       BCSCTL1 &= ~DIVA1;
480
481       IE1 &= ~WDTIE;                                 // disable WDT int.
482       IFG1 &= ~WDTIFG;                               // clear WDT int.
flag
483
484       WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL | WDTSSEL | WDTIS1; // use
WDT as timer, flag each
485                                                                // 512
pulses from ACLK
486
487       while (!(IFG1 & WDTIFG));                      // count 1024
pulses from XT1 (until XT1's
488                                                      // amplitude is OK)
489
490       IFG1 &= ~OFIFG;                                // clear osc. fault
int. flag
491       BCSCTL2 |= SELM0 | SELM1;                      // set XT1 as MCLK
492     }
(gdb)



Reply via email to