USB STACK SELF POWER

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB STACK SELF POWER

Jump to solution
3,480 Views
elettro86
Contributor I

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

Francesco 

Labels (1)
0 Kudos
Reply
1 Solution
3,072 Views
J2MEJediMaster
Specialist I

There should be a button labelled Accept as Solution on the post, near the Reply button. If not, click on the options drop-down menu at the upper right of the post and select Accept as Solution from the drop-down menu that appears.

 

---Tom

View solution in original post

0 Kudos
Reply
19 Replies
3,072 Views
Tsuneo
Contributor IV

> but I can find the solution.

It's never a solution.
Voltage detection at VBUS (5V) pin on the USB connector is required for self-powered device. It's because the stack should disable on-chip D+ pull-up resistor, when no voltage appears at VBUS pin. It's a requirement of USB spec. If your device would still enable D+ pull-up while your PC powers down, the current passing through this pull-up could damage your PC.

If PortG PTGD0 pin is occupied on your board, assign a spare port pin for this purpose. And modify "if(PTGD_PTGD0 == USB_BUS_ATTACHED)" line for this port pin.

Tsuneo

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi Tsuneo,

 

thank for your answer. The problem is that in my PCB  i have no attached USB VOLTAGE (5V) to any microC port so I can not determinate if there is o no 5V by external pin. Is there any software method? 

 

Thanks in advice

Francesco

0 Kudos
Reply
3,072 Views
JimDon
Senior Contributor III

On your board, what is the D+ pullup attached to?

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

I use the internal pull-up

 

Thanks

FRancesco

0 Kudos
Reply
3,072 Views
Tsuneo
Contributor IV

I thought that the USB power supply on S08MM128 is same as those of S08JM, but I was wrong. There is a difference. On S08JM, on-chip USB regulator (VREG) is supplied by VDD pin. But on S08MM, VBUS pin is added to the USB ports, which is supposed to connect to VBUS (5V) pin of the USB connector. On this chip, the on-chip USB regulator (VREG) is supplied by this VBUS pin. Therefore, above leakage current problem doesn't occur on S08MM, even without firmware intervention, if VBUS pin of the chip connects to the VBUS pin of the USB connector.

So far, so good.

The problem is that, there seems no register which detects VBUS voltage change at the VBUS pin of S08MM chip...

Tsuneo

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Ok, thanks Tsuneo. I use the same Power to VDD for the S08MM and for the Device. Is there any software method to determine if VDD of the microC is changed? 

0 Kudos
Reply
3,072 Views
JimDon
Senior Contributor III

elettro86,

The real question is did you connect the VBUS pin of the s08mm chip to the USB connector vbus?

If not you will have to correct your design.

If you look in the MC9S08MM128RM.pdf, in the section 2.3 Recommended System Connections it clearly shows this.

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Yes Jim I do it. I follow this section for my hardware connection, but i have no connected VBUS by external pin.

 

Thanks

Francesco

0 Kudos
Reply
3,072 Views
Tsuneo
Contributor IV

> 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.

You mean,
- VDD pin of the S08MM128 is not supplied
- VBUS pin of the S08MM128 is supplied by USB connector
When VDD pin is supplied, the device is not enumerated by the PC.

While the VDD pin is not supplied,
- What is the voltage of D+ (USB_DP) pin?
- What is the voltage of VDD pin?

I have doubt that any leakage current flows from USB power domain into VDD power domain, while VDD is off. This leakage current disturbs normal start up of the MCU core.

Tsuneo

0 Kudos
Reply
3,072 Views
JimDon
Senior Contributor III

Tsuneo,

No - he did NOT have the VBUS pin connect to the USB connector.

Not sure what the VBUS pin was connected to, but not the connector.

 

0 Kudos
Reply
3,072 Views
Tsuneo
Contributor IV

> elettro86: I follow this section for my hardware connection, but i have no connected VBUS by external pin.
> JimDon: No - he did NOT have the VBUS pin connect to the USB connector.

I took elettro86's post as follows,
- He connected MCU VBUS pin to the VBUS pin of the USB connector.
- But He doesn't connect any extra port pin of the MCU to the VBUS pin.

elettro86, is this right?


On the S08MM reference manual (MC9S08MM128RM.pdf), we find this description.

24.5.1.7 USB Powering and USBDP Pull-up Enable Options
For self-powered applications, VBUS sensing must be built into the application. For instance, a KBI pin interrupt can be utilized (if available). When a valid VBUS connection is made, the KBI interrupt can notify the application that a valid USB connection is available, and the internal pull-up resistor can be enabled using the USBPU bit.

This description suggests that S08MM has dedicated VBUS pin, but any MCU register doesn't reflect VBUS voltage change (VBUS sensing). And then, we have to still connect an extra port pin to VBUS for VBUS sensing, like the case of S08JM. For S08MM, VBUS sensing is required for the USB stack just to identify plug-off apart from Suspend.


But I have an impression that OP's problem doesn't directly relate to VBUS sensing.
So, I asked for another possibilities.

> When I riconnect POWER SOURCE  I also reset the microC with the RESET BUTTON on my board beacuse  I want that the code restart.

How long did you push the RESET BUTTON?
Does longer reset (2-3 seconds) result in any difference?

Tsuneo

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi guy,

 

thaks for your answer.

 

1 - Long reset does not differen result

 

2 - While VDD is not supplied :

-VDD voltage pin is 0.000V 

-D+ pin is 0.01V

-D- pin is 0.01V

-VBUS pin is 5V

 

Is there any firmware or hardware problem?

 

Thanks in advice

Francesco

0 Kudos
Reply
3,072 Views
Tsuneo
Contributor IV

> 1 - Long reset does not differen result
 
> 2 - While VDD is not supplied :
-VDD voltage pin is 0.000V
-D+ pin is 0.01V
-D- pin is 0.01V
-VBUS pin is 5V

Thanks.
This result denies leakage passing from USB power domain to VDD power domain.


OK, here is another possibility: USB reset timing issue.
This test will prove the existence of this problem.

1) Connect a USB hub between your device and the PC.
2) Power cycle your board once.
3) Confirm that the board fails enumeration.
4) On the PC, open Device Manager and find the hub under USB Controller.
At the bottom of the property dialog of the hub, disable the hub once. After a couple of seconds, re-enable the hub.

Does the PC start enumeration of the device?

Disable/ enable of a hub on Device Manager causes bus reset to the device under hub, to which enumeration of the device should follow.

Tsuneo

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi Tsuneo,

 

I try to use the usb hub but the result is the same: host does not enumerate the device. I discovery a very strange thing. When I disconnect POWER SOURCE from the device, appear the CODE - WARRIOR dialog box that notify me that the code-warrior has lost the connection to the device, so he ask to me if a want to retry to stop or retry the debug sessione. If I stop debug session and I subsequently recconect POWER SOURCE to the device host does not enumerate the device. Instead if I don't give answer to the code - warrior dialog box and I subsequently reconnect POWER SOURCE, the debug session is restore, and host is able to enumerate the device. In conclusion, if I desconnect POWER SOURCE, stop the code, reconnect POWER SOURCE, restart the code by the restart button host does not enumerate the device; instead if I don't stopped the code, disconnect POWER SOURCE, reconnect POWER SOURCE, debug session is automatically restore and host is able to enumerate the device. Why this appen?

 

Now I try to insert in my USB code a very simple application: turn led ON-OFF when a TOD interrupt is generated. I disconnect the POWER SOURCE and I subsequently reconnect to POWER SOURCE. My intention is to verify if the application correctly restart. I will inform you about the result of this try.

 

Thank in advice

Francesco

 

 

0 Kudos
Reply
3,072 Views
Tsuneo
Contributor IV

Sound like the debugger holds the MCU core execution at reconnection of the debugger after power cycling.

Is your firmware enumerated after power cycling, when it runs without debugger?

Tsuneo

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi Tsuneo,

 

perhaps I found the mistake. Now I initialize the clock, SIMCO SOPT SPMSC register using the Device Inizializzator code and seem that the stack work fine. I think there were some errors in my init code.

 

Thanks for you help. Have I mark this post as "SOLVED?"

 

Regards

Francesco

 

0 Kudos
Reply
3,073 Views
J2MEJediMaster
Specialist I

There should be a button labelled Accept as Solution on the post, near the Reply button. If not, click on the options drop-down menu at the upper right of the post and select Accept as Solution from the drop-down menu that appears.

 

---Tom

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi Tsuneo, thanks for your answer.

 

I think I can't explain clearly my problem, sorry for this. When I disconnect POWER SOURCE :

 

- VDD pin of S08MM128 is supplied

 

In my custom PCB POWER SOURCE is the same for microC and the device, so when I disconnect POWER SOURCE the microC doesen't WORK. When I riconnect POWER SOURCE  I also reset the microC with the RESET BUTTON on my board beacuse  I want that the code restart.

 

Thanks in advice

Francesco

 

0 Kudos
Reply
3,072 Views
elettro86
Contributor I

Hi Tsuneo,

 

sorry for the previous message. I'm crazy. Yes I mean this:

 

- VDD pin of the s08mm is not supplied

-VBUS is supplied by USB connector

 

When VDD pin is supplied is not enumerate by the PC.

 

Sorry for the previous message

 

Francesco

 

0 Kudos
Reply