[SOLVED] embOS + embUSB-Device and Cortex M3 (LPC1768) is working GOOD!...

  • Hi, I am beginner. I`v downloaded SES 4.12. I have a trial licence.

    I`v compiled "SeggerEval_emPower_emUSBD_Audio_SES_180424" example good. This is Cortex-M4 controller.

    But I create new project with LPC1768 (Cortex-M3). I`v tried to compile for LPC1768 controller and I have received any errors :

    undefined reference to `OS_InitKern_STD'
    undefined reference to `OS_InitHW'
    undefined reference to `OS_CreateTask_DP'
    ...

    As I understood the difference in #define OS_CPU_HAS_VFP - (Floating Point)

    Can you recommend me anything?

    ---------------------------- The problem has resolved with Cortex-M3 (LPC 1768) ! ---------------------------------------

    I install the ESPRO package.

    I have used the RTOS.h from ......\SEGGER Embedded Studio\v3\packages\ESPRO\OS\Inc

    I have used the libraries from .....\SEGGER Embedded Studio\v3\packages\ESPRO\OS\Lib\:
    libos_v7m_t_le_dp.a - debug
    libos_v7m_t_le_r.a - release

    I have compiled my project normal.

    Embedded Studio is really good idea! Now will try USB-HID attached...

    Thank you for attention!

    Edited 4 times, last by kkmspb (April 10, 2019 at 6:52 PM).

  • Hello kkmspb,

    great to hear it's working now.

    Just as a clarification: We're renaming some API functions to prevent incompatible setups. "OS_CPU_HAS_VFP" depends on the architecture/core options passed to the compiler and renames the OS_InitKern() (OS_Init() in V5) function, while the OS_LIBMODE_* definitions rename the OS_CreateTask() (OS_TASK_Create() in V5) to ensure the compatibility to the linked embOS library. If no OS_LIBMODE_* definition is set by the user, OS_LIBMODE_DP will be used by default.

    Best regards,
    Michael

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi Michael!


    Thank you for your answer.

    I have launched next project with emOS normal.

    But I meet a problem with emUSB (on LPC1768) . I have spend two days with situation below:

    Code
    while ((USBD_GetState() & (USB_STAT_CONFIGURED | USB_STAT_SUSPENDED)) != USB_STAT_CONFIGURED) 
    {      
    BSP_ToggleLED(0);      
    USB_OS_Delay(50);    
    }

    When I turn on controller after USB-Start() USBD_GetState() returned 0x10 (=USB_STAT_ATTACHED)


    After 2-3 seconds USBD_GetState() returned 0x11 (=USB_STAT_ATTACHED&USB_STAT_SUSPENDED)

    When I connected USB cabel the USBD_GetState() returned also 0x11.

    This occured with examples : USB_HID_Keyboard.c , USB_CDC_Echo.c , USB_HID_Mouse.c ...

    USBLyzer and Control Panel Windows did not show any new device...

    I forget to add the USB log:
    0:000 MainTask - USBD_Start
    0:000 MainTask - *** Warning *** Bus RESET should not occur in unattached state!

    Edited 4 times, last by kkmspb: The problem is resolved! (April 10, 2019 at 6:54 PM).

  • The device does not seem to enumerate. Could you please set a breakpoint in the USB ISR routine and see if you arrive there when you connect the cable to your PC?

    I see that you have used an emPower project as a base, it will not work on the LPC1768 out of the box as it is a completely different MCU...

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • When I connect USB cabel I step here

    Code
    void USB_IRQHandler(void){  
      OS_EnterInterrupt();
    
    
      if (_pfUSB_ISRHandler)  {    
        _pfUSB_ISRHandler();   // here step occured
      }  
      OS_LeaveInterrupt();
    }

    I suppose that maybe:
    1. I have downloaded at first emPower example with MK66 (HS USB) and changed it to LPC1768(FS USB).
    2. I am disturbed about USB frequency settings.

    Do you recommend me some example for like LPC1768 controller with emOS and emUSB-Device? I searched it at forum and downloaded area but I not found anything.

  • We do not have a package for LPC1768 readily available. Please check the NXP SEGGER Eval Software page https://www.segger.com/evaluate-our-software/nxp/ maybe you can download a package for a different MCU which is also available to you.

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Yes - the problem was resolved during 3 days!

    Bus RESET should not occur in unattached state! - This is important message that i get on any examples permanently with my LPC1768 board.

    This board is from old receipt printer. This is not evaluation board.

    And USB D+ must be pull-up to 3.3V by 1.5K resistor. This is assigned to Host that the Device have FULL Speed Rate.

    I.E. this was not software problem - this was the hardware mistake.

    Thank all!

  • I 'v tried to compile the USB_HID_Keyboard.c example from ...SEGGER\SEGGER Embedded Studio\v3\packages\ESPRO\USBD\Application


    and Release Version is working good (symbols is sended normal to PC to Text Editor), but in Debug version its does not send to PC.


    In Debug Mode by JLink debugger the controller stop here:

    Code
    while ((USBD_GetState() & (USB_STAT_CONFIGURED | USB_STAT_SUSPENDED)) != USB_STAT_CONFIGURED) 
    {
          BSP_ToggleLED(0);
          USB_OS_Delay(50);
    }
    // USB_STAT_CONFIGURED is not occures


    As I have understood the controller run to OS_Error(OS_STATUS ErrCode) with OS_ERR_SYS_STACK and hang here :


    Code
    void OS_Error(OS_STATUS ErrCode) 
    {
      OS_EnterRegion();  // Avoid further task switches
      OS_DICnt = 0u;     // Allow interrupts so we can communicate with embOSView
      OS_EI();
      OS_Status = ErrCode;
      while (OS_Status) { // !!!!!!!   here
        // Endless loop may be left by setting OS_Status to 0
      }
    }

    I suppose "OS_LIBMODE_DP" needs lib not libusbd_v7m_t_le_d.a but libusbd_v7m_t_le_dp.a ?

    Code
    #if DEBUG
      #define OS_LIBMODE_DP
    #else
      #define OS_LIBMODE_R
      #define OS_VIEW_IFSELECT  OS_VIEW_DISABLED  // embOSView communication is disabled per default in release configuration
    #endif

    Or maybe you recommend me any something?

  • Hello kkmspb,

    OS_ERR_SYS_STACK indicates an overflow of the System Stack. Can you increase the stack size and repeat your test? Does the issue persist?

    The reason the application "works" in release is that embOS will not perform stack checking in release configurations. Thus it will not call OS_Error(). But the stack could still have overflown in release as well, which may still result in a faulty application. Hence, we typically advise to develop in debug configurations and move to release only after the debug configuration was proven to work correctly.

    I suppose "OS_LIBMODE_DP" needs lib not libusbd_v7m_t_le_d.a but libusbd_v7m_t_le_dp.a ?

    I'm not sure whether I understand this question correctly. The OS_LIBMODE_* define is relevant to embOS only, while the cited libraries seem to be USB libraries. There's no dependency between those.

    Best regards,
    Martin

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Thank Martin!

    static OS_STACKPTR int Stack0[768];
    I change the 768 value to my controller max 6xxx (LPC1768) but it doesn't resolve my problem.


    Well, I will teach embOS carefully....

  • Hello kkmspb,

    It seems you're increasing the stack size for one task. However, you'd need to increase the System Stack size instead. This can be done in the project options under "Code -> Runtime Memory Area -> Main Stack Size".

    Best regards,
    Martin

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!