AnsweredAssumed Answered


Question asked by Francesco Pallottini on Jul 10, 2011
Latest reply on Jul 13, 2011 by Tom Thompson

Hi everyone,


(sorry for my bad English)


I'm using the USB STACK for S08JM60. My custom PCB use the S08MM128 so I have done the code porting since the USB module for JM60 or MM128 is the same. The stack seems work well but I have a problem. My device is a SELF POWER device but  I have no attached the USB BUS to any pin so I can't use Keyboard Interrupt for detect if USB bus is connect. When my device is plugged in the STACK work fine and when I dissconet USB cable from the host (my PC) the stack work fine; in fact as the device is plugged again the host enumerates the device again.  The problem is when I disconnect POWER SOURCE from my PCB. In this case when I connect again the POWER SOURCE host can't enumerate the device. I think that the problem is in my Check_USBBUS_Status ( ) routine but I can find the solution. In this routine the Freescale check for the Bus connection using PTGD port I can't use this. Can anyone help me? This is the code of Check_USBBUS_Status ( ) and main.c ()



void Check_USBBus_Status(void){     //if(PTGD_PTGD0 == USB_BUS_ATTACHED)         /* Is JM60 attached on USB bus? */ //{              if(CTL_USBEN == 0)                     /* JM60 module off ? */         {            EPCTL0 = 0x0D;            INTSTAT = 0xBF;            CTL = 0x00;            INTENB = 0x00;                      /* disable USB interrupt*/            CTL_USBEN = 0x01;                   /* enable module */            USBCTL0 = UCFG_VAL;                 /* attach JM60 to USB bus*/            Usb_Device_State = ATTACHED_STATE;               }             //}        //else    //{    //  if(CTL_USBEN == 1)                      /*  JM60 USB on ?*/    //   {    //       CTL = 0x00;                        /* disable module */    //       INTENB = 0x00;                     /* mask USB interrupt*/    //       Usb_Device_State = POWERED_STATE;          //    }    //}           if(Usb_Device_State == ATTACHED_STATE)      {         INTSTAT = 0xBF;                        /*clear USB interrupts*/         INTENB = 0xBF;                                  }    if(Usb_Device_State == USB_ENTER_SUSPEND)    {        USB_Suspend();    }}
void main(void) {  UINT8 u8Counter;  /* System Initalization */  Init_Sys();                     /* Enable Interrupts Macro */  EnableInterrupts;           /* Main Loop */  for(;;)   {    /* USB Manager, please keep it in main Loop */    Check_USBBus_Status();                  } }



Thank in advice