• AVR Freaks

Hot!USBEN turns off automatically if FCMEN or IESO is on

Author
pajuhesh80
Super Member
  • Total Posts : 101
  • Reward points : 0
  • Joined: 2019/12/08 11:23:37
  • Location: Nowshahr, Mazandaran, Iran
  • Status: offline
2020/08/04 10:28:00 (permalink)
0

USBEN turns off automatically if FCMEN or IESO is on

I copied and edited mla HID Bootloader USB codes to use them in my app (MCU: PIC18F14K50).
It works but there are some strange things:
I used "while(mHIDRxIsBusy()) SLEEP();" to enter IDLE mode while waiting for data (IDLEN is set). If I don't send any data for some seconds, device clock stops. I'm sure because a timer toggles LATB (an LED) each 250ms and LED freezes (on or off) after some seconds. It is not suspend mode because my code turns off LEDs (not freeze) while entering suspend.
I tried to use Fail-Safe clock feature to find the problem but it caused even more problem! If I enable FCMEN or IESO, USBEN turns off after about 0.1s. Windows doesn't response to device connection at all. Used "while(1) LATBbits.LATB6 = UCONbits.USBEN;" to read USBEN bit as I don't have debug header.
Does anyone have any idea about the source these problems? If you need, I can upload my project.
I used FCMEN on anther USB project based on mla HID custom on exactly this MCU and it worked fine.

Slow and Steady!
#1

1 Reply Related Threads

    pajuhesh80
    Super Member
    • Total Posts : 101
    • Reward points : 0
    • Joined: 2019/12/08 11:23:37
    • Location: Nowshahr, Mazandaran, Iran
    • Status: offline
    Re: USBEN turns off automatically if FCMEN or IESO is on 2020/08/05 00:53:23 (permalink)
    0
    I found something: Looks like device enters suspend just after USB initialization for a short time. This is my code for suspend mode:
    LATB = LATC = 0;
    UIE = 0b00000100;
    UIRbits.IDLEIF = 0;
    UCONbits.SUSPND = 1;
    i = OSCCON;
    OSCCONbits.IDLEN = 0;
    while(!UIRbits.ACTVIF);// SLEEP();
    OSCCON = i;
    LATB = 0xff;
    UCONbits.SUSPND = 0;
    while(UIRbits.ACTVIF){UIRbits.ACTVIF = 0;}
    UIE = 0b01111011;

    if I uncomment "SLEEP();" and FCMEN is on, USBEN turns off automatically. Looks like oscillator stop due to sleep mode disables USBEN. However, based on datasheet info, this should not happen. I can't understand why turning FCMEN on causes this. FCMEN isn't triggered at all. If it detect failure, blinker LED should blink much slower. I tried it by removing crystal oscillator.
    post edited by pajuhesh80 - 2020/08/05 01:23:06

    Slow and Steady!
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5