AnsweredAssumed Answered

S08JM60 USB CDC Virtual com problem

Question asked by Rastislav Matula on Oct 9, 2011
Latest reply on Mar 16, 2012 by Erich Styger



I would like to start using the USB communication (Virtual com port) between S08JM60 and PC. I downloaded the source files for USB CDC virtual com demo for this board. I am using CodeWarrior 10.1 under Windows 7 64bit with OSBDM programmer (USBDM JB16 firmware). Also I use this driver file and I am using Processor Expert to configure the project. This is first time I am trying to get USB working, so there could be some beginners mistake, which I am not aware of.


I managed to change the project demo program so there is as little code as possible (e.g: No SD card, FAT or SPI interface). I am trying just so send simple characters, and receive them by Terminal under windows.


/* Including needed modules to compile this module/procedure */#include "Cpu.h"#include "Events.h"#include "LED1.h"#include "LED2.h"#include "LED3.h"/* Include shared modules, which are used for whole project */#include "PE_Types.h"#include "PE_Error.h"#include "PE_Const.h"#include "IO_Map.h"/* User includes (#include below this line is not maintained by Processor Expert) */#include "usb.h"#include "usb_cdc.h"#define TIME_DELAY 5000void main(void){ /* Write your local variable definition here */ unsigned char i;  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization.                    ***/   /* Write your code here */ //SOPT1_COPT=0; //cdc_in=uart_in=0xff+1;                /* USB CMX Init */ usb_cfg_init(); cdc_init();  while(1) {     cdc_process();                      /* USB CMX CDC process */     Cpu_Delay100US(TIME_DELAY);          for(i=0; i<30; i++)     {   LED1_SetVal();    cdc_putch('0'+i);   //cdc_getch();      Cpu_Delay100US(TIME_DELAY);      LED1_ClrVal();   LED2_ClrVal();   LED3_ClrVal();   Cpu_Delay100US(TIME_DELAY);     } }  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/  for(;;){}  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/


With my OSBDM programmer i am unfortunately unable to Debug the program, because of the high frequency needed by USB (24MHz/48MHz). So at least I am using LEDs to check at which point the code is working OK.


Till now I was able to send one series of characters (30 cycles of "for") until the "cdc_process()" is called again. At this point are the characters send to the terminal correctly (30characters: 0,1,2 - M).  After that the usb communication get stuck. The code continues running, but is not passing inside the if condition (in cdc_process() function):


  /* If tx buffer is not empty, start transmission. */  if (!usb_ep_is_busy(CDC_TX_EP_NO) && (tx_ndx != 0)) {   /* Check the status of the next transfer. */   switch (usb_ep_error(CDC_TX_EP_NO)) {   case USBEPERR_PROTOCOL_ERROR: /* Ignore error, send next chunk. */   case USBEPERR_HOST_ABORT:   case USBEPERR_NONE: /* Finished with no error. */    /* Start sending next chunk. */    LED2_SetVal();    usb_send(CDC_TX_EP_NO, (void *) 0, (void *) cur_tx_buffer,      tx_ndx, tx_ndx);    /* Switch buffer. */    tx_ndx = 0;    cur_tx_buffer = (hcc_u8*) ((cur_tx_buffer      == (hcc_u8*) tx_buffer1) ? tx_buffer2 : tx_buffer1);    break;   case USBEPERR_USER_ABORT:   case USBEPERR_TO_MANY_DATA:   default:    /* Upps! unexpected error. Stop here. */    CMX_ASSERT(0);   }

 I am pretty sure, there are data in buffer, as I am sending them continually, so there have to be problem with  "busy endpoint". With my Debugging LEDs I am not able investigate any further :-)  And I am starting to be a little frustrated, because of many problems, which I had. And after resolving one arises another bigger one...


Is there anybody who has experienced similar problem? Or just some advice to get me back on track...


I will appreciate any help! Thanks in advance.