Board freezing/loosing connection

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Board freezing/loosing connection

1,518件の閲覧回数
MO_84
Contributor III

Hello again,

 

I started experiencing some problems with my board. I'm using the dragon 12 plus board.

 

Here is the problem:

 

I'm losing connection with the HCS12 board as soon as I run a program (by clicking on the green arrow on the true-time simulator window). I keep on getting the attached error message.

The strange thing is that the exact same program was working prior to this issue.

This happened all of a sudden.

 

I have attached the program that I'm currently using and giving me the issues.

The program uses PORTH to set the duty cycle of PWM0.

 

#include <hidef.h>      /* common defines and macros */#include "derivative.h"      /* derivative-specific definitions */void PWM0_ini(unsigned char prescale_factor, unsigned char period, unsigned char init_duty);void main(void){    DDRH = 0x0;     //Make PTH as input for DIP Switches     DDRB = 0xFF;    //PORTB as output since LEDs are connected to it    DDRJ = 0xFF;    //PTJ as output to control Dragon12+ LEDs    PWM0_ini(0x03,255,0); /* initialize PWM */                          /* prescale to divide by 8 results in 1MHz clock or 1 usec per pulse */                          /* period of 255 is 255 usec */    DDRB=0xFF; // Port B set to output    while(1)    {        PWMDTY0=PTH;/* set duty cycle using PORTH (PTH) dip switches */        PORTB=PWMDTY0;    }}void PWM0_ini(unsigned char prescale_factor, unsigned char period, unsigned char init_duty){    PWMPRCLK = prescale_factor; /* choose 8-bit PWM, set clock A prescaler to prescale_factor */                                /* choose clock A as clock source, PWM channel 0 output high                                    at the beginning of the period */    PWMPOL = 0x01;    PWMCAE = 0x00; /* The next statements selects left-aligned */    PWMCTL = 0x80; /* halt PWM clock in wait mode */    PWMPER0 = period; /* set period of PWM0 to 0.1 ms */                      /* period in sec = 1/(bus clock / prescale_factor) * PWMPER0 */                      /* (PWMPER0-PWMDTY0)/PWMPER0*100% */    PWMDTY0 = init_duty; /* set duty cycle to (period-init_duty) /period *100% */    PWME |= 0x01; /* enable PWM0 channel */}

 

 

I have also tried other programs and they all cause the same problem.

I have tried reinstalling codewarrior and the USB-serial driver which didn't help.

 

Does anyone have any suggestions on troubleshooting this problem?

 

Any help would be much appreciated.

 

Thanks,

Mo

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

1,049件の閲覧回数
Lundin
Senior Contributor IV

What happens on the CPU reset pin when you lose connection with the board? Is it stable on 5V or do you get reset pulses?

 

What happens when you try to single step?

0 件の賞賛
返信

1,049件の閲覧回数
MO_84
Contributor III

It works when I single step through.

It only looses connection when I click on "Hault". Is that normal?

 

Another question:

 

When I'm debugging my code, I usually set up a breakpoint and then single step through.

I have noticed that the value of my variables are not displayed correctly in the data window.

For example:

 

while(1)
    {
       
          PORTB = frequency_int;
    
    }

 

Even though the PORTB LED's stay constant when I run the code, when I single step through the value of frequency_int constanly changes. Is this normal?

Is there a way I can step through my program with the correct variables being displayed?

 

Thanks again for the tech support.

 

Mo

0 件の賞賛
返信

1,049件の閲覧回数
Lundin
Senior Contributor IV

This smells very much like a stack overflow. Are you using lots of global variables? Allocate a larger stack and see if that helps. In CW this is done in the .prm file:

 

STACKSIZE 400  /* 400 bytes of stack space */

 

 

Also make sure that some code actually sets the stack pointer. By default this is done in some CW startup code. The LDS instruction should be executed with the correct address.

 

0 件の賞賛
返信

1,049件の閲覧回数
MO_84
Contributor III

I'm using a total of 10 global variables.

I made the change as you recommended from STACKSIZE 0x100; to STACKSIZE 400;

 

 

It fixed the problem for some of the variables but not all of them. Specifically the integers were displayed correctly but all floats were still changing.

 

Any other ideas.

 

Thanks

0 件の賞賛
返信