{"id":3628,"date":"2014-03-29T07:09:20","date_gmt":"2014-03-29T07:09:20","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/problem-about-atmel-collection-of-common-programming-errors\/"},"modified":"2014-03-29T07:09:20","modified_gmt":"2014-03-29T07:09:20","slug":"problem-about-atmel-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/problem-about-atmel-collection-of-common-programming-errors\/","title":{"rendered":"problem about atmel-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7e63bf4a1b58e41d7fb15314cd53664e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJames<br \/>\nmicrocontroller avr pcb-design atmel xmega<br \/>\nProblem: I get Errors when trying to connect to the MicroController using the PDI interface. How does a MicroController behave when it hasn&#8217;t been programmed? Is there a pin that will toggle to show me it&#8217;s OK? Kind of a hardware &#8220;Hello World&#8221;?I would like a way to confirm if the MicroController has failed or if I&#8217;ve done something else wrong.Additional Information:I&#8217;ve designed and had manufactured a custom board for an Atmel XMEGA MicroController, ATXMega64D3 to be exact. I&#8217;m using the ATXMega<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9923db0355e953a34c28a5dd66d444d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBobStein-VisiBone<br \/>\nexception-handling arduino interrupt-handling atmel atsam3x<br \/>\nOccasionally I will get an unexpected interrupt, and my code will hang inside Dummy_Handler() in exceptions.c of the Atmel Studio Framework (ASF). I am using the ATSAM3X8E microcontroller of the Arduino Due.void Dummy_Handler(void) {while(1) {} }Any ideas how to determine which interrupt it was? Of course I could replace this single handler with unique dummy handlers, one for each exception. (There are about fifty of them.) For example change each line in the same exceptions.c file:void HardF<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/ENqfL.jpg?s=32&amp;g=1\" \/><br \/>\nnonsensickle<br \/>\nc uart atmel cortex-m3<br \/>\nI&#8217;ve stumbled across a peculiar problem with my PDC (Peripheral DMA Controller) where using the PDC to transfer a constant string from flash over UART 0 seems to produce an unexpected result. The correct number of bytes is sent but they are all zero.The string is defined in the global namespace as followschar* str = &#8220;Hello world!&#8221;;I only send it once at the start of main like this:UART0-&gt;UART_TPR = str; \/\/ PDC transfer pointer UART0-&gt;UART_TCR = strlen(str); \/\/ PDC count<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2e0abc12b61d55d2b3dc726073cdda71?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChetan Bhargava<br \/>\narduino programming atmel compiler atmel-studio<br \/>\nI see that on the official Arduino website, the reference page contains the functions and vales you would use specified to the Arduino compiler. http:\/\/arduino.cc\/en\/Reference\/HomePageWhat would you use instead, if you are working with Atmel Studio?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/86b9f964b2a1d7cc66a78a6199801f71?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmFeinstein<br \/>\nvoltage-regulator atmel avr32 uc3<br \/>\nI am not pretending to use this, but as a general curiosity, when the AT32UC3C2512C datasheet says in page 1259, Table 40-20, parameter Iout, that the internal 3.3V regulator has a 35mA DC output current, does it mean I can actually use it as a power source, as long as I don&#8217;t use more then 35mA out of it? EDIT:As requested:<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/995c17fee02de7ea30b970890f615d74?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMaus<br \/>\narm linux-device-driver embedded-linux atmel<br \/>\nI&#8217;m customising Linux for an ARM9 Atmel AT91SAM960 board. In the device file Atmel named all the USART the same atmel_usart. Of course with id enumeration:static struct platform_device at91sam9260_uart0_device = {.name = &#8220;atmel_usart&#8221;,.id = 1,.dev = { &#8230;} }According to the Linux Device model, all these devices (5 UARTS on a SAM9260) would be bind to the driver named atmel_usart.I don&#8217;t want to set a TTYS driver on all UARTS which will be registerd. I have severa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/df23b8c11c0268a0a7ce9db736e06277?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDaniel Hedberg<br \/>\natmel<br \/>\nIn AVR programming with atmega32, I can&#8217;t assign a value to an array. I am getting the error:Assignment of read-only str[i]What am I doing wrong?My code is:const char str[1000]; void Serial_tx(unsigned char ch) {for (i = 0; i &lt; 10; i++){str[i] = ch;} }<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4f9899a028a87ab8991049808f91a717?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncyphunk<br \/>\narduino avr atmel timer<br \/>\nIs it possible to monitor a block of code and determine the number of processor clock cycles that code took on an Arduino and\/or AVR atmel processor? or, should I rather monitor microseconds passed before and after code run? Note: I&#8217;m not concerned with real time (as in, how many real seconds passed) as much as I am in &#8220;how many clock cycles does this code require from the CPU&#8221;The current solution I can come up with is from time.c:#define clockCyclesPerMicrosecond() ( F_CPU \/ 1000000L ) #define<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/acb829898ee9c9df38d6e94827167823?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeterJ<br \/>\nc# atmel<br \/>\nI am adapting some test software that is used to upload a .bin file to one of our products via USB. The product has a Atmel AT91SAM7X256 processor. The software is all written in c# and is running on a windows XP machine.The previous programmer (no longer with the company) uses a dll file called AT91BootDLL.dll to scan USB ports for an ateml processor and obtain an handle on it. Then it can open a USB connection and do various things like read, write etc. This all works fine but every now and th<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2b3631deb607f3f3ef38827324fc9390?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntrygvis<br \/>\narduino usb atmel lufa<br \/>\nI have an Arduino Uno r3 board which has an atmega16u2 chip that normally contains the usb to serial firmware that allows the board to communicate with the IDE. I have been learning how to flash that chip with different firmwares that let it act as other types of USB devices ( Keyboard \/ Mouse specifically ). I have found some hex files that I can use online, but I am trying to learn how to build my own version of the keyboard and mouse hex files.Here are the variables that I&#8217;ve set in the make<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/12790ee3b6ffe6d598e7a6a779e5c2d6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSVFeingold<br \/>\nc increment avr atmel<br \/>\nHaving a strange problem. I finally figured out how to turn a variable &#8220;i&#8221; that increments inside a loop into a string that I can pass to a function which turns it into a character that is output to a display. The trouble is, the value increments by 2 rather than by 1! I have tried a few different things but I&#8217;m not sure where the problem lies. Initially, I thought that perhaps, if you have a function that calls another function, and they both use the same variable to increment (i.e. for(int i=0<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9043a8082fb439bfcb6599d029ce108c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSpectrem<br \/>\narduino atmel avr-studio5 avr-studio4<br \/>\nI have tried setting up AVR studio 5.1 and 6 to use my Arduino libraries. The instructions I have followed are here: http:\/\/www.engblaze.com\/tutorial-using-avr-studio-5-with-arduino-projects\/ My project includes the necessary libraries and they are within the same directory. They have also been added to the project within AVR Studio. I am still having issues with undefined references to everything.My questions are: How can I fix this issue? Does anyone else have these same issues after jumping t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5e0a5a18efcafd37d8495839faed111b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLong Hoang<br \/>\nlinux microcontroller avr avr-gcc atmel<br \/>\nI have a ATXMega16a4u mcu of Atmel and try to compile code with avr-gcc 4.7.2 (Fedora 4.7.2-1.fc17). I got this error:Unrecognized argument in option &#8216;-mmcu=atxmega16a4u&#8217;So I tried to compile code with -mmcu=atxmega16a4 (without &#8216;u&#8217; in the end). And get some &#8216;undeclared&#8217; errors:error: &#8216;ADC_CH_GAIN_DIV2_gc&#8217; undeclared (first use in this function)Is my microcontroller not supported yet by avr-gcc? Is there any possibility to make it work on Fedora, avoiding using avr studio (and windows)?Thanks Lo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b55e4dbf038d9b93c7fb588a9a207a6d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnonsensical<br \/>\nc function extern cortex-m3 atmel<br \/>\nI&#8217;ve been trying to understand the linkage error that I&#8217;m getting regarding the _sbrk function and stumbled across this function definition in a library.extern caddr_t _sbrk(int incr);\/\/ &#8230; some other definitions &#8230;extern caddr_t _sbrk(int incr) { static unsigned char *heap = NULL; unsigned char *prev_heap;if (heap == NULL) {heap = (unsigned char *)&amp;_end; } prev_heap = heap;heap += incr;return (caddr_t) prev_heap; }Now, I know what extern does on a function declaration but I don&#8217;t know its<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8e2aa7fd262b7c4b6f53a89a52f527f9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTravis Griggs<br \/>\nc embedded valgrind avr atmel<br \/>\nI&#8217;m working on an embedded program. I use the avr-gcc tool chain to compile the C source from my MacBook Pro. Until recently things have been going pretty well. In my latest development iteration though, I seem to have introduced some sort of intermittent bug that I&#8217;m suspecting is some sort of stack or other memory corruption error.I&#8217;ve never used Valgrind, but it seems it gets rave reviews, but most of the references seem to refer to malloc\/free types of errors. I don&#8217;t do any malloc&#8217;ing. It&#8217;s<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/96f5e5d858f1562ac8075c2664451b3b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nvsz<br \/>\nc assembly embedded atmel<br \/>\nThe short story:What are those reset conditions, which will not set a bit in MCUSR of an ATmega processor, but still cause a reset?The long story:I use brown-out detection in an ATmega168, and have a place in my code to handle it. If my system loses power, a capacitor keeps it above brown-out level for around a half second, and when I restore power, the brown-out handling routine successfully runs. (I check the brown-out bit in the MCUSR)However, when I slowly decrease voltage on the system, and<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b190162e26aefd50ecfff8f6d0e4ba5f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\notto<br \/>\ncompilation avr-gcc atmel<br \/>\nInstructions in the blinky.zip, gcc-section, Teensy++ v.2. Makefile and blinky.c are in the zip. I modified the blinky.c by defining F_CPU at the start because not using Makefile, please, see below. So why do I get the errs and how can I compile the C-files for at90usb1286 chip?$ avr-gcc -mmcu=atmega88 blinky.cIn file included from blinky.c:28: \/usr\/local\/lib\/gcc\/avr\/4.2.2\/..\/..\/..\/..\/avr\/include\/util\/delay.h:90:3: warning: #warning &#8220;Compiler optimizations disabled; functions from &lt;util\/delay<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d71f75f55e62e0278ac9d8a8766397af?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDC177E<br \/>\narm atmel<br \/>\nI&#8217;m creating a simple program to familiarize myself with Atmel Studio 6 (running on Win 7 X64), using the ASF supplied libraries\/drivers for a SAM4S microcontroller. In compiling, I get several (19) undefined reference errors on the startup_sam4s.c file. I have heard that this usually implies a file missing from project\/missing linker files, but I&#8217;m (reasonably) confident that I have added all required files into my solution.The errors are all of the &#8220;undefined reference to _szero&#8221; sort, and are<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/122f88b15efac96280558e3e5e8482df?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njorrebor<br \/>\nc++ include atmel<br \/>\nthis code:#include &#8220;SoftwareSerial.h&#8221;&gt; #include &lt;avr\/io.h&gt; #include &lt;HardwareSerial.h&gt; #include &lt;avr\/interrupt.h&gt;void read_response();int main () {sei();Serial.begin(2400);uint8_t receivePin = 2;uint8_t transmitPin = 3;SoftwareSerial softSerial(receivePin, transmitPin);softSerial.begin(2400);while(1){softSerial.println(&#8220;to soft serial&#8221;);Serial.print(softSerial.read());} }gives me this error at compile time:undefined reference to `SoftwareSerial::SoftwareSerial(unsigned ch<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/12790ee3b6ffe6d598e7a6a779e5c2d6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSVFeingold<br \/>\nide header-files atmel<br \/>\nI know there are a lot of questions on this topic, and I&#8217;ve looked through a fair number of them. However I am still having problems. I started writing a test program for a prototype PCB, and now that it&#8217;s grown to nearly 1000 lines I&#8217;m trying to break it up into libraries that I can use for particular functions. I thought this would be very simple. Make .c and .h files for each library that I need. I.e. I would have OLED.h and OLED.c for functions that control an OLED display. Copy the appropr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/DfkK6.jpg?s=32&amp;g=1\" \/><br \/>\nAnubis<br \/>\narduino atmel avrdude<br \/>\nI&#8217;ve just got my first brand new Arduino mega 2560 board. I&#8217;ve downloaded Arduino 1.0.1 software. When I first plugged in the board, it failed to detect the device. So I opened device manager and pointed to the &#8220;&#8230;\\arduino-1.0.1\\drivers&#8221; folder to update the driver for the unidentified Arduino Mega 2560 device.Now comes my first problem; (O\/S is window 7 32bit)Following warning came. I chose to install anyway. Is that wrong??However driver is successfully installed.Then I opened Arduino 1.0.1<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8d7ecc33f727fe807606ebbe3dd8e2f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHeather<br \/>\nc cross-compiling atmel<br \/>\nWhen compiling Atmel example with arm cross-compiler getting :..\/at91lib\/utility\/stdio.c:64:8: error: variable &#8216;r&#8217; has initializer but incomplete typethe code is :struct _reent r = {0, (FILE *) 0, (FILE *) 1, (FILE *) 0};I don&#8217;t know what can I do here since first I need here is to understand what this code must mean?And then can I re code it for my compiler? Or must I downgrade compiler to some other version?My version : arm-unknown-linux-uclibcgnueabi-gcc (Buildroot 2012.05-git-00423-g4205dbd)<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>James microcontroller avr pcb-design atmel xmega Problem: I get Errors when trying to connect to the MicroController using the PDI interface. How does a MicroController behave when it hasn&#8217;t been programmed? Is there a pin that will toggle to show me it&#8217;s OK? Kind of a hardware &#8220;Hello World&#8221;?I would like a way to confirm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3628","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3628"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3628\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}