STM32F072C8 USB CDC

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

STM32F072C8 USB CDC

Post by halba »

Hello,

I have problem to get running the USB CDC on the STM32F072C8 with ChibiOS hal. The USB CDC setting is same like in the ChibiOS_3.0.0p3\testhal\STM32\STM32F0xx\USB_CDC example but when is called

Code: Select all

chprintf((BaseSequentialStream *)&SDU1, "Hello World");
the transmitting in SDU1 is set to 2 and nothing is send. The SDU1 and registers looks like this:
CDC_issue.png
CDC_issue.png (57.79 KiB) Viewed 7779 times


Do you have any idea what is wrong? CDC example from ST works well on the same HW.

Thanks,
halba
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F072C8 USB CDC

Post by Giovanni »

Hi,

It looks like the device has been enumerated by the host, so the USB driver is working.

"Hello World" is in the output queue, could you expand "ob"? that would tell us if the string has been sent.

Giovanni
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

Re: STM32F072C8 USB CDC

Post by halba »

Yes, I can see it like the STMicroelectronics Virtual COM Port (COM3). The ST stsw-stm32102_commPortDriver v1.4.0 driver is installed.
CDC_ob.png
CDC_ob.png (25.17 KiB) Viewed 7775 times
The rest of the ob are 0.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F072C8 USB CDC

Post by Giovanni »

I forgot, please also "oqueue", that will show if the string is still waiting in the buffer or has been sent.

In the main(), what you do after sending the string?

Giovanni
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

Re: STM32F072C8 USB CDC

Post by halba »

CDC_oqueue.png
CDC_oqueue.png (43.26 KiB) Viewed 7768 times


I do nothing special after chprintf is called, there is only periodically updated display through SPI, scanned buttons and that is all. Shoul I call something after chprintf? Here is whole main, it is little bit mess, I am just verifying peripherals:

Code: Select all

/*
    ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/
#include "ch.h"
#include "hal.h"
#include "test.h"
#include "buttons.h"
#include "display.h"
#include "bxcan.h"
#include "eeprom.h"
#include "crc.h"
#include "chprintf.h"
#include "shell.h"

/*
 * Endpoints to be used for USBD1.
 */
#define USBD1_DATA_REQUEST_EP           1
#define USBD1_DATA_AVAILABLE_EP         1
#define USBD1_INTERRUPT_REQUEST_EP      2


/*
 * Serial over USB Driver structure.
 */
static SerialUSBDriver SDU1;

extern OneButton Button[];
uint8_t u8Rate = 10;
uint8_t u8Test = 0;

uint8_t i2cTxBuffer[2] = {0x00, 0xAB};
uint8_t i2cRxBuffer[8];
uint8_t status = 0;

uint8_t u8EEPDataWrite[7] = {1, 2, 3, 4, 5, 6, 7};
uint8_t u8EEPDataRead[8];
uint8_t *pu8EEPDataWrite = u8EEPDataWrite;
uint8_t *pu8EEPDataRead = &u8Test;

uint8_t filtID;
uint8_t *pfiltID = &filtID;
uint8_t length;
uint8_t *plength = &length;
uint8_t tempo = 2;

void tick100ms(void);

static const SPIConfig spi1cfg = {
  NULL,
  /* HW dependent part.*/
  NULL,
  NULL,
  SPI_CR1_MSTR | SPI_CR1_BR_0 | SPI_CR1_SSI | SPI_CR1_SSM,
  SPI_CR2_FRXTH | SPI_CR2_DS_0 | SPI_CR2_DS_1 | SPI_CR2_DS_2
};

static const CANConfig cancfg = {
  CAN_MCR_NART,
  CAN_BTR_SJW(3) | CAN_BTR_TS2(0) | CAN_BTR_TS1(3) | CAN_BTR_BRP(7)
};

static const I2CConfig i2cfg1 = {
    STM32_TIMINGR_PRESC(0x02) | STM32_TIMINGR_SCLH(0x09) | STM32_TIMINGR_SCLL(0x0E),
    I2C_CR1_PE,
    I2C_CR2_AUTOEND
};

static const PWMConfig pwmcfg = {
  1000000,                                    /* 1000000 1us - 1MHz PWM clock frequency.   */
  250,//2273,                                    /* 250 Initial PWM period 250us - 4kHz       */
  NULL,
  {
   {PWM_OUTPUT_ACTIVE_HIGH, NULL},
   {PWM_OUTPUT_ACTIVE_LOW, NULL},
  },
  NULL,
  NULL
};

/*
 * USB Device Descriptor.
 */
static const uint8_t vcom_device_descriptor_data[18] = {
  USB_DESC_DEVICE       (0x0110,        /* bcdUSB (1.1).                    */
                         0x02,          /* bDeviceClass (CDC).              */
                         0x00,          /* bDeviceSubClass.                 */
                         0x00,          /* bDeviceProtocol.                 */
                         0x40,          /* bMaxPacketSize.                  */
                         0x0483,        /* idVendor (ST).                   */
                         0x5740,        /* idProduct.                       */
                         0x0200,        /* bcdDevice.                       */
                         1,             /* iManufacturer.                   */
                         2,             /* iProduct.                        */
                         3,             /* iSerialNumber.                   */
                         1)             /* bNumConfigurations.              */
};

/*
 * Device Descriptor wrapper.
 */
static const USBDescriptor vcom_device_descriptor = {
  sizeof vcom_device_descriptor_data,
  vcom_device_descriptor_data
};


/* Configuration Descriptor tree for a CDC.*/
static const uint8_t vcom_configuration_descriptor_data[67] = {
  /* Configuration Descriptor.*/
  USB_DESC_CONFIGURATION(67,            /* wTotalLength.                    */
                         0x02,          /* bNumInterfaces.                  */
                         0x01,          /* bConfigurationValue.             */
                         0,             /* iConfiguration.                  */
                         0xC0,          /* bmAttributes (self powered).     */
                         50),           /* bMaxPower (100mA).               */
  /* Interface Descriptor.*/
  USB_DESC_INTERFACE    (0x00,          /* bInterfaceNumber.                */
                         0x00,          /* bAlternateSetting.               */
                         0x01,          /* bNumEndpoints.                   */
                         0x02,          /* bInterfaceClass (Communications
                                           Interface Class, CDC section
                                           4.2).                            */
                         0x02,          /* bInterfaceSubClass (Abstract
                                         Control Model, CDC section 4.3).   */
                         0x01,          /* bInterfaceProtocol (AT commands,
                                           CDC section 4.4).                */
                         0),            /* iInterface.                      */
  /* Header Functional Descriptor (CDC section 5.2.3).*/
  USB_DESC_BYTE         (5),            /* bLength.                         */
  USB_DESC_BYTE         (0x24),         /* bDescriptorType (CS_INTERFACE).  */
  USB_DESC_BYTE         (0x00),         /* bDescriptorSubtype (Header
                                           Functional Descriptor.           */
  USB_DESC_BCD          (0x0110),       /* bcdCDC.                          */
  /* Call Management Functional Descriptor. */
  USB_DESC_BYTE         (5),            /* bFunctionLength.                 */
  USB_DESC_BYTE         (0x24),         /* bDescriptorType (CS_INTERFACE).  */
  USB_DESC_BYTE         (0x01),         /* bDescriptorSubtype (Call Management
                                           Functional Descriptor).          */
  USB_DESC_BYTE         (0x00),         /* bmCapabilities (D0+D1).          */
  USB_DESC_BYTE         (0x01),         /* bDataInterface.                  */
  /* ACM Functional Descriptor.*/
  USB_DESC_BYTE         (4),            /* bFunctionLength.                 */
  USB_DESC_BYTE         (0x24),         /* bDescriptorType (CS_INTERFACE).  */
  USB_DESC_BYTE         (0x02),         /* bDescriptorSubtype (Abstract
                                           Control Management Descriptor).  */
  USB_DESC_BYTE         (0x02),         /* bmCapabilities.                  */
  /* Union Functional Descriptor.*/
  USB_DESC_BYTE         (5),            /* bFunctionLength.                 */
  USB_DESC_BYTE         (0x24),         /* bDescriptorType (CS_INTERFACE).  */
  USB_DESC_BYTE         (0x06),         /* bDescriptorSubtype (Union
                                           Functional Descriptor).          */
  USB_DESC_BYTE         (0x00),         /* bMasterInterface (Communication
                                           Class Interface).                */
  USB_DESC_BYTE         (0x01),         /* bSlaveInterface0 (Data Class
                                           Interface).                      */
  /* Endpoint 2 Descriptor.*/
  USB_DESC_ENDPOINT     (USBD1_INTERRUPT_REQUEST_EP|0x80,
                         0x03,          /* bmAttributes (Interrupt).        */
                         0x0008,        /* wMaxPacketSize.                  */
                         0xFF),         /* bInterval.                       */
  /* Interface Descriptor.*/
  USB_DESC_INTERFACE    (0x01,          /* bInterfaceNumber.                */
                         0x00,          /* bAlternateSetting.               */
                         0x02,          /* bNumEndpoints.                   */
                         0x0A,          /* bInterfaceClass (Data Class
                                           Interface, CDC section 4.5).     */
                         0x00,          /* bInterfaceSubClass (CDC section
                                           4.6).                            */
                         0x00,          /* bInterfaceProtocol (CDC section
                                           4.7).                            */
                         0x00),         /* iInterface.                      */
  /* Endpoint 3 Descriptor.*/
  USB_DESC_ENDPOINT     (USBD1_DATA_AVAILABLE_EP,       /* bEndpointAddress.*/
                         0x02,          /* bmAttributes (Bulk).             */
                         0x0040,        /* wMaxPacketSize.                  */
                         0x00),         /* bInterval.                       */
  /* Endpoint 1 Descriptor.*/
  USB_DESC_ENDPOINT     (USBD1_DATA_REQUEST_EP|0x80,    /* bEndpointAddress.*/
                         0x02,          /* bmAttributes (Bulk).             */
                         0x0040,        /* wMaxPacketSize.                  */
                         0x00)          /* bInterval.                       */
};

/*
 * Configuration Descriptor wrapper.
 */
static const USBDescriptor vcom_configuration_descriptor = {
  sizeof vcom_configuration_descriptor_data,
  vcom_configuration_descriptor_data
};

/*
 * U.S. English language identifier.
 */
static const uint8_t vcom_string0[] = {
  USB_DESC_BYTE(4),                     /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  USB_DESC_WORD(0x0409)                 /* wLANGID (U.S. English).          */
};

/*
 * Vendor string.
 */
static const uint8_t vcom_string1[] = {
  USB_DESC_BYTE(38),                    /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
  'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
  'c', 0, 's', 0
};

/*
 * Device Description string.
 */
static const uint8_t vcom_string2[] = {
  USB_DESC_BYTE(56),                    /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  'C', 0, 'h', 0, 'i', 0, 'b', 0, 'i', 0, 'O', 0, 'S', 0, '/', 0,
  'R', 0, 'T', 0, ' ', 0, 'V', 0, 'i', 0, 'r', 0, 't', 0, 'u', 0,
  'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0, 'M', 0, ' ', 0, 'P', 0,
  'o', 0, 'r', 0, 't', 0
};

/*
 * Serial Number string.
 */
static const uint8_t vcom_string3[] = {
  USB_DESC_BYTE(8),                     /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  '0' + CH_KERNEL_MAJOR, 0,
  '0' + CH_KERNEL_MINOR, 0,
  '0' + CH_KERNEL_PATCH, 0
};

/*
 * Strings wrappers array.
 */
static const USBDescriptor vcom_strings[] = {
  {sizeof vcom_string0, vcom_string0},
  {sizeof vcom_string1, vcom_string1},
  {sizeof vcom_string2, vcom_string2},
  {sizeof vcom_string3, vcom_string3}
};

/*
 * Handles the GET_DESCRIPTOR callback. All required descriptors must be
 * handled here.
 */
static const USBDescriptor *get_descriptor(USBDriver *usbp,
                                           uint8_t dtype,
                                           uint8_t dindex,
                                           uint16_t lang) {

  (void)usbp;
  (void)lang;
  switch (dtype) {
  case USB_DESCRIPTOR_DEVICE:
    return &vcom_device_descriptor;
  case USB_DESCRIPTOR_CONFIGURATION:
    return &vcom_configuration_descriptor;
  case USB_DESCRIPTOR_STRING:
    if (dindex < 4)
      return &vcom_strings[dindex];
  }
  return NULL;
}

/**
 * @brief   IN EP1 state.
 */
static USBInEndpointState ep1instate;

/**
 * @brief   OUT EP1 state.
 */
static USBOutEndpointState ep1outstate;

/**
 * @brief   EP1 initialization structure (both IN and OUT).
 */
static const USBEndpointConfig ep1config = {
  USB_EP_MODE_TYPE_BULK,
  NULL,
  NULL,
  NULL,
  0x0040,
  0x0040,
  &ep1instate,
  &ep1outstate,
  1,
  NULL
};

/**
 * @brief   IN EP2 state.
 */
static USBInEndpointState ep2instate;

/**
 * @brief   EP2 initialization structure (IN only).
 */
static const USBEndpointConfig ep2config = {
  USB_EP_MODE_TYPE_INTR,
  NULL,
  NULL,
  NULL,
  0x0010,
  0x0000,
  &ep2instate,
  NULL,
  1,
  NULL
};

/*
 * Handles the USB driver global events.
 */
static void usb_event(USBDriver *usbp, usbevent_t event) {

  switch (event) {
  case USB_EVENT_RESET:
    return;
  case USB_EVENT_ADDRESS:
    return;
  case USB_EVENT_CONFIGURED:
    chSysLockFromISR();

    /* Enables the endpoints specified into the configuration.
       Note, this callback is invoked from an ISR so I-Class functions
       must be used.*/
    usbInitEndpointI(usbp, USBD1_DATA_REQUEST_EP, &ep1config);
    usbInitEndpointI(usbp, USBD1_INTERRUPT_REQUEST_EP, &ep2config);

    /* Resetting the state of the CDC subsystem.*/
    sduConfigureHookI(&SDU1);

    chSysUnlockFromISR();
    return;
  case USB_EVENT_SUSPEND:
    return;
  case USB_EVENT_WAKEUP:
    return;
  case USB_EVENT_STALLED:
    return;
  }
  return;
}

/*
 * USB driver configuration.
 */
static const USBConfig usbcfg = {
  usb_event,
  get_descriptor,
  sduRequestsHook,
  NULL
};

/*
 * Serial over USB driver configuration.
 */
static const SerialUSBConfig serusbcfg = {
  &USBD1,
  USBD1_DATA_REQUEST_EP,
  USBD1_DATA_AVAILABLE_EP,
  USBD1_INTERRUPT_REQUEST_EP
};


/*
 * Blue LED blinker thread, times are in milliseconds.
 */
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {

  (void)arg;
  chRegSetThreadName("thBlinker1");
  while (true) {
    //palClearPad(GPIOB, 15);
    //GPIOB->ODR &= ~0x8000;
    chThdSleepMilliseconds(20);
    //palSetPad(GPIOB, 15);
    //GPIOB->ODR |= 0x8000;
    chThdSleepMilliseconds(20);
  }
}

/*
 * Green LED blinker thread, times are in milliseconds.
 */
static THD_WORKING_AREA(waThread2, 128);
static THD_FUNCTION(Thread2, arg) {

  (void)arg;
  chRegSetThreadName("thBlinker2");
  while (true) {
    //palClearPad(GPIOB, 14);
    chThdSleepMilliseconds(u8Rate);
    //palSetPad(GPIOB, 14);
    chThdSleepMilliseconds(u8Rate);
  }
}

static THD_WORKING_AREA(waThread3, 512);
static THD_FUNCTION(Thread3, arg) {

  (void)arg;
  chRegSetThreadName("thButtons");
  while (true) {
    tick100ms();
    chThdSleepMilliseconds(100);
  }
}

static THD_WORKING_AREA(waThread4, 512);
static THD_FUNCTION(Thread4, arg) {

  (void)arg;
  chRegSetThreadName("thDispalyUpdate");
  while (true) {
    display_update();
    chThdSleepMicroseconds(100);
    palSetPad(GPIOB, 4);
    //chThdSleepMicroseconds(100);
    palClearPad(GPIOB, 4);
    chThdSleepMilliseconds(1000);
  }
}

//static THD_WORKING_AREA(waThread5, 512);
//static THD_FUNCTION(Thread5, arg) {
//
//  (void)arg;
//  chRegSetThreadName("godfather");
//  while (true) {
//    if(u8Test == 1)
//    {
//      chThdSleepMilliseconds(1000*tempo);
//      TIM15->ARR = 2403;
//      chThdSleepMilliseconds(250*tempo);
//      TIM15->ARR = 2273;
//      chThdSleepMilliseconds(250*tempo);
//      TIM15->ARR = 2145;
//      chThdSleepMilliseconds(1250*tempo);
//      TIM15->ARR = 2273;
//      chThdSleepMilliseconds(750*tempo);
//      TIM15->ARR = 2865;
//      chThdSleepMilliseconds(3000*tempo);
//      TIM15->ARR = 2273;
//      chThdSleepMilliseconds(1000*tempo);
//      TIM15->ARR = 2403;
//      chThdSleepMilliseconds(250*tempo);
//      TIM15->ARR = 2273;
//      chThdSleepMilliseconds(250*tempo);
//      TIM15->ARR = 2145;
//      chThdSleepMilliseconds(1250*tempo);
//      TIM15->ARR = 2273;
//      chThdSleepMilliseconds(750*tempo);
//      TIM15->ARR = 3030;
//      chThdSleepMilliseconds(3000*tempo);
//      TIM15->ARR = 2273;
//    }
//    chThdSleepMilliseconds(100);
//  }
//}

/*
 * Application entry point.
 */
int main(void) {
  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.`
   */

  halInit();
  SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP; //premapovani I2C na DMA kanaly 6 a 7
  chSysInit();
 
  CRC_Init();
  canFiltersInit();

  /*
   * Activates the serial driver 1 using the driver default configuration.
   * PA9 and PA10 are routed to USART1.
   */
//  sdStart(&SD1, NULL);
//  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1));       /* USART1 TX.       */
//  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1));      /* USART1 RX.       */

  //SPI works
  canStart(&CAND1, &cancfg);
  spiStart(&SPID1, &spi1cfg);
  i2cStart(&I2CD1, &i2cfg1);
  usbStart(&USBD1, &usbcfg);
  pwmStart(&PWMD15, &pwmcfg);

  shellInit();

  /*
   * Creates the blinker threads.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
  chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO, Thread3, NULL);
  chThdCreateStatic(waThread4, sizeof(waThread4), NORMALPRIO, Thread4, NULL);
//  chThdCreateStatic(waThread5, sizeof(waThread5), NORMALPRIO, Thread5, NULL);
 
  /*
   * Initializes a serial-over-USB CDC driver.
   */
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);

  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   * Note, a delay is inserted in order to not have to disconnect the cable
   * after a reset.
   */
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(1500);
  usbStart(serusbcfg.usbp, &usbcfg);
  usbConnectBus(serusbcfg.usbp);
 
 
  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state, when the button is
   * pressed the test procedure is launched with output on the serial
   * driver 1.
   */
  while (true) {
//    if (palReadPad(GPIOA, GPIOA_PIN0))
//      TestThread(&SD1);
    chThdSleepMilliseconds(500);
  }
}

void tick100ms(void)
{
  button_scan();
 
  if(Button[0].flags & BTN_SHORT)
  {     
    //u8Rate = u8Rate + 10;
    //EEP_writeUint8(0x10, 0x11);
    //EEP_writePageUint8(0x00, u8EEPDataWrite, 0x07);
    u8EEPDataWrite[0]++;
   
    chprintf((BaseSequentialStream *)&SDU1, "Hello World");
   
//    pwmEnableChannel(&PWMD1, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
//    pwmEnableChannel(&PWMD1, 3, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
   
    Button[0].flags &= ~(BTN_SHORT);
  }
 
  if(Button[1].flags & BTN_SHORT)
  {
    //EEP_readUint8(0x06, pu8EEPDataRead);
    //EEP_readPageUint8(0x00, u8EEPDataRead);
    //bxCAN_ReadDataFIFO0(NULL, pfiltID, i2cRxBuffer, plength);
   
    //pwmEnableChannel(&PWMD15, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD15, 5000));
    //pwmEnableChannel(&PWMD15, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD15, 5000));
   
    u8Test = 1;
   
    Button[1].flags &= ~(BTN_SHORT);
  }
 
  if(Button[2].flags & BTN_SHORT)
  {     
    bxCAN_SendDataMailbox2(0xAC, i2cTxBuffer, 2);
    //pwmDisableChannel(&PWMD15, 0);
    //pwmDisableChannel(&PWMD15, 1);
    //TIM15->CCER &= ~(0x01 | 0x10);
    //TIM15->BDTR = 0;
   
//    pwmEnableChannel(&PWMD15, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD15, 5000));
//    pwmEnableChannel(&PWMD15, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD15, 5000));
   
    Button[2].flags &= ~(BTN_SHORT);
  }
 
  if(Button[2].flags & BTN_LONG)
  {
    bxCAN_ReadDataFIFO1(NULL, pfiltID, i2cRxBuffer, plength);
   
    Button[2].flags &= ~(BTN_LONG);
  }
}
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F072C8 USB CDC

Post by Giovanni »

Only the "H" has been consumed from the queue, data does not get requested by the host for some reason, the thread is waiting on the queue for more requestes.

Do you have a terminal emulator opened on the COM port?

Giovanni
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

Re: STM32F072C8 USB CDC

Post by halba »

It doesn't matter if there is opened terminal (RealTerm) or not, I was trying also only with some USB sniffer (USBlyzer) and even without sniffer and the behavior is always same.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F072C8 USB CDC

Post by Giovanni »

I will try that on the discovery board as soon as possible but I don't really expect problems. Does the standard demo work for you?

Another suggestion, please enable stack check, parameters checks, assertions and state checker in chconf.h if you haven't already done that. Those option can catch most common errors.

Giovanni
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

Re: STM32F072C8 USB CDC

Post by halba »

I didn't try the original demo, will check it later, what is the fastest way to run it in the IAR? Or should I install ChibiStudio? After enabling the system checks I there is no error related to USB, I just fixed some error related to CAN filters. Thank you for your help.
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

Re: STM32F072C8 USB CDC

Post by halba »

Another observation, I was trying to send some data from PC to embedded side, the data (5 chars) are received to the iqueue and ib, but the system is stuck on the unhandled exception. Can I somehow figure out what is the reason? It seems that some interrupts aren't properly assigned.
Post Reply