element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Code switcher
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 15 replies
  • Answers 2 answers
  • Subscribers 420 subscribers
  • Views 1780 views
  • Users 0 members are here
Related

Code switcher

royston02
royston02 over 12 years ago

I am learned to program in arduino but i want to use all the space available.Is it possible to make a software that takes arduino code and switches it over to avr studio or is it not required at all? I don't want a book to learn programming in avr studio but is it possible to turn arduino wiring to avr studio format without rewriting the whole program to avr studio format?image

 

Code switcher

 

  • Sign in to reply
  • Cancel

Top Replies

  • mcb1
    mcb1 over 12 years ago in reply to royston02 +1
    Guess you've got the answer then.
Parents
  • ipv1
    0 ipv1 over 12 years ago

    I will answer your question, but I want to ask you why you need to do so? Arduino's processing language is build on Cplus plus with some keywords added and functions added to ease the understanding of what you are writing. Any programming language is a way of describing the functionality that you want to implement. It's the compiler's job to take what you told it and turn it into machine code which is basically a reduced set of instructions (hence the name RISC) and make things work. E.g.

    [code]

    unsigned char i=5;

    while(i>=0){

         i--;

    }

    [/code]

    should get translated to something like

    [code]

              mov Rn, #05h ; where Rn is any register number or

    loop1: djnz Rn, loop1

    [/code]

     

    Now the way I see it, code in Arduino and code in AVR studio will not make much of a difference in terms of the space used because of the IDE. Optimum space usage is possible if:

    1. The compiler and it's optimizations.

    2. The code writer understands how the compiler will convert and writes good quality code with an understanding of the architecture. E.g. the above example will be better than if you use float instead of the UCHAR and worst if you try using FOR LOOP that counts up instead of the decremented WHILE loop.

     

    -> So if you are worried about wasting space with extra code, I suggest you write programs in assembly(like I do some times) or understand the AVR architecture and the compiler's output to the code you write.

     

    -> The reason why most people use an Arduino is because it's easier to use and lots of example code out there so stop worrying about it and focus on solving the problem with you brilliant code in processing

     

    Answer.: IMHO you can use use AVR studio to compile Arduino/Processing Code IF you can port all the supporting files to work with AVR Studio. There is no code translator as such for converting processing to CPP but then they are just encapsulations.

    I think now a days everything uses the GCC compiler for AVR so it will not make that big of a difference.

    One alternative I can suggest is using Eclipse and control the entire process of building code. A tutorial on how to set it up is given at http://embeddedcode.wordpress.com

     

    | If this answer is satisfactory please click helpful answer or correct answer.|

     

    Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • ipv1
    0 ipv1 over 12 years ago

    I will answer your question, but I want to ask you why you need to do so? Arduino's processing language is build on Cplus plus with some keywords added and functions added to ease the understanding of what you are writing. Any programming language is a way of describing the functionality that you want to implement. It's the compiler's job to take what you told it and turn it into machine code which is basically a reduced set of instructions (hence the name RISC) and make things work. E.g.

    [code]

    unsigned char i=5;

    while(i>=0){

         i--;

    }

    [/code]

    should get translated to something like

    [code]

              mov Rn, #05h ; where Rn is any register number or

    loop1: djnz Rn, loop1

    [/code]

     

    Now the way I see it, code in Arduino and code in AVR studio will not make much of a difference in terms of the space used because of the IDE. Optimum space usage is possible if:

    1. The compiler and it's optimizations.

    2. The code writer understands how the compiler will convert and writes good quality code with an understanding of the architecture. E.g. the above example will be better than if you use float instead of the UCHAR and worst if you try using FOR LOOP that counts up instead of the decremented WHILE loop.

     

    -> So if you are worried about wasting space with extra code, I suggest you write programs in assembly(like I do some times) or understand the AVR architecture and the compiler's output to the code you write.

     

    -> The reason why most people use an Arduino is because it's easier to use and lots of example code out there so stop worrying about it and focus on solving the problem with you brilliant code in processing

     

    Answer.: IMHO you can use use AVR studio to compile Arduino/Processing Code IF you can port all the supporting files to work with AVR Studio. There is no code translator as such for converting processing to CPP but then they are just encapsulations.

    I think now a days everything uses the GCC compiler for AVR so it will not make that big of a difference.

    One alternative I can suggest is using Eclipse and control the entire process of building code. A tutorial on how to set it up is given at http://embeddedcode.wordpress.com

     

    | If this answer is satisfactory please click helpful answer or correct answer.|

     

    Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • royston02
    0 royston02 over 12 years ago in reply to ipv1

    but still can anyone write a proper tutorial for not only me but others and will help a lot of them to save memory space and would be very grateful if someone told how to do it on chips which don't support arduino bootlader like atmega324pa etc.image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 12 years ago in reply to royston02

    this should be a good place to start   http://arduino.cc/en/Hacking/Programmer

     

    Regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • ipv1
    0 ipv1 over 12 years ago in reply to royston02

    Without the bootloader, you can program a chip using an In-System Programmer. I use http://dangerousprototypes.com/docs/Bus_Pirate_AVR_Programming

    It's cheap(er) and can be used for many other things too.

    Be careful and be sure to configure the flags right.

     

    Hope this helps,

    IP

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube