AtXmega128A3U - CDC library under MPLAB X

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

I am currently using Microchip MPLAB X IDE to develop my AVR projects. I'd like to add an USB-CDC support to one of them.

I was able to find some old ASF example, made with Atmel Studio 6.1. I needed to convert it AS7 to be able to import it to MPLAB X.

Importing process was finished, but code doesn't compile. It looks like some files are missing.

 

Is it possible do add CDC library to my project manually? 

Attachment(s): 

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

Aren't there current examples in AS7 ?

 

What about START ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Aren't there current examples in AS7 ?

 

Maybe, but I do not use AS7. It is Windows only tool - this is why I prefer MPLAB X.

 

Quote:
What about START ?

 

Do you mean https://start.atmel.com/?

It seems not to offer any USB Middlewares for AtXmega128A3U...

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

awneil wrote:
Aren't there current examples in AS7 ?

atlantis86 wrote:
Maybe, but I do not use AS7.

but you wrote:
I needed to convert it AS7

My point was, why not start with an AS7 project - rather than mess about trying to convert 6 to 7

 

I prefer MPLAB X

Note that MPLAB forums are here:

 

https://www.microchip.com/forums/f499.aspx

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. May 22, 2020 - 09:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Note that MPLAB forums are here:

 

https://www.microchip.com/forums/f499.aspx

 

 

Yes, but this is a library related issue rather than IDE related issue.

Forum mentioned by you is rather devoted to PIC microcontrollers.

I simply would like to know if there is some "raw" version of CDC library for AtXmega, which I could manually add to my project. The same it can be done with FatFS library for example.

Last Edited: Fri. May 22, 2020 - 10:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

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

 

Ok, I m trying to add the first one to my project. It compiles but get two weird warnings:

 

</p>
<p>/tmp/ccnpK1h1.s: Assembler messages:<br />
/tmp/ccnpK1h1.s:846: Warning: Quoted section flags are deprecated, use attributes instead</p>
<p> </p>
<p>usb/usb_xmega.c: In function 'usb_ep_start_in':<br />
usb/usb_xmega.c:83:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]<br />
  e->DATAPTR = (unsigned) data;</p>
<p>

 

Any ideas?

Last Edited: Fri. May 22, 2020 - 03:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It would help to show the code to which those lines relate.

 

The second one should be self-explanatory:

cast from pointer to integer of different size

try googling "Wpointer-to-int-cast" for more info - see: https://www.avrfreaks.net/commen...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

It would help to show the code to which those lines relate.

 

I can't... These are some temporary files, generated by the compiler and then quickly removed.

 

Quote:
try googling "Wpointer-to-int-cast" for more info - see: https://www.avrfreaks.net/commen...

 

Will this be a sufficient solution?

 

e->DATAPTR = (unsigned) (volatile uint8_t *) data;

 

And another, more important question. I can't locate any example nor figure it out by function names. How to send and receive data via CDC, using this library?

Last Edited: Fri. May 22, 2020 - 04:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

atlantis86 wrote:

I can't... These are some temporary files, generated by the compiler and then quickly removed.

Use -save-temps when building.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Impossible to say what would be appropriate without knowing the context.

 

But, as the original warning says, it is very suspicious to be trying to make something that's the wrong size for a pointer be a pointer!

 

you'd need to contact the author of the library for support with their library.

 

EDIT

 

The Github page does point you to an example that uses it ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. May 22, 2020 - 04:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:

-save-temps

 

Ok, now i see it points to the main.s:

 

</p>
<p>.global    usb_xmega_endpoints<br />
    .section    .data,"aw",@progbits<br />
.p2align 1;,bss<br />
    .type    usb_xmega_endpoints, @object<br />
    .size    usb_xmega_endpoints, 16</p>
<p>

 

So it looks like the following define in usb_xmega.h is causing the problem.

 

</p>
<p>#define GCC_FORCE_ALIGN_2  __attribute__((section (".data,\"aw\",@progbits\n.p2align 1;")))</p>
<p>

 

How should I modify it?

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

Are you using [ code ] tags by any chance. As you can see they don't work correctly on this forum, use <> on the toolbar.

 

As for forcing alignment, there's a data attribute for that.

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

clawson wrote:

Are you using [ code ] tags by any chance. As you can see they don't work correctly on this forum, use <> on the toolbar.

 

Thanks. I didn't notice that.

 

Quote:
As for forcing alignment, there's a data attribute for that.

 

Do you mean something like that?

 

#define GCC_FORCE_ALIGN_2  __attribute__((data))

 

Unfortunately, this ends up with:

 

main.c:24:1: warning: 'data' attribute directive ignored [-Wattributes]
Last Edited: Fri. May 22, 2020 - 07:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, read the manual about "function attributes" and "data attributes". There is an attribute you can apply to data objects to force their alignment.
.
EDIT relevant manual page...
.
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes

Last Edited: Sat. May 23, 2020 - 11:48 AM