Mohammad Shekarforoush

Board freezing/loosing connection

Discussion created by Mohammad Shekarforoush on Jan 10, 2011
Latest reply on Jan 12, 2011 by Mohammad Shekarforoush

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

Outcomes