Atmel Start - can't get USB examples to work

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Folks,

 

New to SAM, coming from AVR background. Using Atmel Start, latest version of Atmel Studio and a Arduino Feather M0 (SAMD 21).  I'm using the Arduino bootloader/bossac  so setting a section start in the linker to 0x2000 in all projects.

 

All the standard USB 'example projects' work a treat (CDC, HID etc). The equivalent projects from Atmel Start don't. Well, a basic "flash LED" project works but anything USB related doesn't.  Symptoms include windows not seeing any USB device or reporting that a device isn't working.  

 

Anyone else got experience of Atmel Start with the Feather  M0?

 

Cheers,

 

Rob

 

Last Edited: Mon. Aug 22, 2016 - 10:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Rob,

 

I have tried the USBCDCEchoforSAML21XplainedPro Atmel Start project and it fails also.  The examples from ASF worked for me, but there seems to be something wrong with the "Atmel Start" USB examples.

 

Regards,

Larry

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tried to change the clock rate to 48 MHz . ?
Regards
Joachim

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Clock configuration seems to plague Atmel Start.  I reported a problem back in May with the following issue:   

 

 

· Go to http://start.atmel.com/

· Browse examples

· Select USB HID Mouse

· Open selected example

· Highlight SAM D21 Xplained Pro and press select board

· Go to Clocks tab and you will see USB clock is 8MHz

· Look at code and you will see it is 8MHz in peripheral_gclk_config.h

· Download code and this code has USB set to 48MHz
 

It was resolved but looks like something similar has returned.

 

 

David

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

this is really bad, this issue is happening for the second/third time. One would expect better from Atmel/Microchip. I will check with Atmel support and see if this can be fixed as soon as possible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Instead of using the multiplied clock (ie 48 Mhz) they are using the core clock (Almost always <16Mhz). So this does not work. Just choosing a correct clock(ie GCLK) will fix this issue.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Agreed but the sample should work 'out of the box' otherwise (to paraphrase Eric Morecambe) 'everything is in the sample but not necessarily in the right order'.  http://www.dailymotion.com/video...​ 10:40 

 

David 

 

<edit> typo

Last Edited: Thu. Dec 29, 2016 - 10:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been trying to get the USB CDC example to work for the SAMD21 Xplained Pro and tried changing the clock configuration to 48MHz but with no result.

 

If anyone has any working Atmel Start USB code (preferably the CDC example) or could verify that the Atmel Start example doesn't work, or maybe can get it to work, I'd be very grateful.

 

Ideally Atmel should provide working examples and on the clocks configuration page, there should be warnings if certain configurations don't work. Instead, it just won't export code.

 

Sam

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had them working but I'm off to the Netherlands with work, back Thursday if you can wait until I return.

 

David 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That'd be great thanks. Sam

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Sam, 

 

I didn't have a copy of the CDC example so I downloaded the one from Start and confirmed it does not enumerate.  Change peripheral_gclk_config.h​ to the attached and then the USB initialises correctly. 

 

David

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David

 

Okay that works, only oddity was that the file was called peripheral_clk_config.h on my system. The program memory usage is 4.8%, whilst the data memory usage is a massive 31.9% although this may be the same for ASF CDC example.

 

Do you know if this is real data memory usage or whether there would be something strange like memory start address causing this?

On a SAMD21E17A which is the device I'll ultimately want to run the code on, that would mean 60% of SRAM would be full. A SAMD21E16A would have "120%" of its SRAM filled and I hadn't ruled out wanting to use that variant.

 

Thanks

Sam

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Sam, 

 

Apologies for confusion over name I actually copied the contents from one file into the sample file and didn't check the name.  I haven't looked at the CDC sample other than getting it working by sorting out the clocks so can't help you with memory usage.  I agree, it does sound excessive. 

 

David

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right, I tried creating a new START project for the SAMD21E17A, copying all the details from the example, then swapped out the clock configuration with the one you provided.

 

I won't get the hardware to test it on for another few days, but the flash usage was 9.5% (12476 bytes) and the SRAM usage 38.8% (6352 bytes). This makes me think that the start address for the SRAM is at around 30% as the actual code size should be the same.

 

I'll do some investigation and report back.

 

Sam

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David, I also have the similar issues, could you give me a hand

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using Atmel sam3x8e to add USB CDC device, from ASF, follow its Quick start guide

Content of conf_clock.h for SAM3X, SAM3A devices (UOTGHS: USB OTG High Speed):

// USB Clock Source fixed at UPLL.

#define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL

#define CONFIG_USBCLK_DIV 1

 

 

#define UDI_CDC_ENABLE_EXT(port) my_callback_cdc_enable()

extern bool my_callback_cdc_enable(void);

#define UDI_CDC_DISABLE_EXT(port) my_callback_cdc_disable()

extern void my_callback_cdc_disable(void);

#define UDI_CDC_LOW_RATE

 

#define UDI_CDC_DEFAULT_RATE 115200

#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1

#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE

#define UDI_CDC_DEFAULT_DATABITS 8

#include "udi_cdc_conf.h" // At the end of conf_usb.h file

 

 

initialization code

sysclk_init();

irq_initialize_vectors();

cpu_irq_enable();

board_init();

sleepmgr_init(); // Optional

 

 

 

static bool my_flag_autorize_cdc_transfert = false;

bool my_callback_cdc_enable(void)

{

my_flag_autorize_cdc_transfert = true;

return true;

}

void my_callback_cdc_disable(void)

{

my_flag_autorize_cdc_transfert = false;

}

void task(void)

{

if (my_flag_autorize_cdc_transfert) {

udi_cdc_putc('A');

udi_cdc_getc();

}

}

But the result is can't into my_callback_cdc_enable function

Any can help me ?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 11    CMD    99 00 00 00  00 00 00 00                          40.1.0        
               e0 19 2b 8e  00 e0 ff ff                          40.1.8        
               00 00 00 00  00 00 00 00                          40.1.16       
               00 00 00 00  00 00 00 00                          40.1.24       
  11    SSTS   00                        pending                 40.2.0        
  11.0  CTL    80 06 00 01  00 00 40 00  GET DESCRIPTOR          41.1.0        
  11.0  USTS   c0000011                  xact error              41.2.0        
  11    CMD    99 00 00 00  00 00 00 00                          42.1.0        
               e0 19 2b 8e  00 e0 ff ff                          42.1.8        
               00 00 00 00  00 00 00 00                          42.1.16       
               00 00 00 00  00 00 00 00                          42.1.24       
  11    SSTS   00                        pending                 42.2.0        

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had the hardest time getting USB device mode to recognize on the PC using the SAMS70 (failed to get device descriptors), couldn't get it to work at all with ASF but finally got it to work with softpack 1.5 (which I believe is the atmel start libraries). I had to add a delay after the clock was unfrozen, it seems that the lock bit in the register was not enough for it. We've built several boards up now and initially 10us was enough but some needed more so we settled on 25us.

 

in usbhs.h

 

__STATIC_INLINE void USBHS_UnFreezeClock(Usbhs *pUsbhs)

{

    pUsbhs->USBHS_CTRL &= ~((uint32_t)USBHS_CTRL_FRZCLK);

    delay_us(25);

}

 

I had a support ticket with atmel about this and tried their suggestions of different register values but ultimately this was the only thing that would solve the problem.

Last Edited: Tue. Apr 18, 2017 - 02:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SBK_Lou:

 

I checked my code include unfreeze_clock, but it should finished since there is a while loop after ..

// Check USB clock
    otg_unfreeze_clock();
    while (!Is_otg_clock_usable());

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

finally I got the answer

 

 

compiler.h   Line 585

#   define clz(u)              ((u) ? __builtin_ctz(u) : 32)

modified to #   define clz(u)              ((u) ? __builtin_clz(u) : 32)

 

Atmel release wrong or I used the wrong setting, I don't know, but I spent a week to find this

and thanks for other guys in the other website share this for me.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 11    SSTS   00                                                  pending                 13.2.0        
  11.0  CTL    80 06 00 01  00 00 40 00                            GET DESCRIPTOR          14.1.0        
  11.0  IN     12 01 00 02  02 00 00 40  eb 03 04 24  00 01 01 02  .......@...$....        14.2.0        
               03 01                                               ..                      14.2.16       
  11    CMD    99 00 00 00  00 e0 ff ff  c0 36 c2 52  00 e0 ff ff                          15.1.0(2)     
               00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00                       

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm having the same problem - none of the examples work on my SAMS70N19 board (though SAM-BA out of ROM does work). 

 

Neither of the suggested solutions helps. I tried adding the 25 µs delay after manipulating the FRZCLK bit and that didn't do anything, and the macro for clz(u) (which was elsewhere and looked different) was not incorrect.

 

The peripheral clock include file looks correct to me.

 

I've taken a basic MSC device example from Atmel Start, added code into usb_start() to call usbd_msc_example() (so that it does all of the attaching and call back registration) and nothing happens at all.

 

I've gotten all of the rest of the peripherals working. USB is the last thing that isn't functioning (but, of course, it's the most important one).