Assmber code in C project

Go To Last Post
59 posts / 0 new

Pages

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

Clawson: Sorry that I didn't explain myself clearly enough, here's a link: https://garynuman.com/

 

As for the other stuff... I do not want to drop into a command line compiler, build, import, etc. I just want to use studio to do everything 'in the project structure' do you understand what I mean by that?

 

As I said in the first post (in a galaxy long ago...) all I want to do is add a handful of assembler instructions into my project.

 

void SomeCfunction(void)

/** DOXYGEN stuff>>>

{     Kill Interrupts

       ASM

       // read an I/O line

       // wait for I/O line to go high

      // set another I/O line

      // wait 10 clocks (@12MHz)

      // set another I/O line

      // clear 1st I/O line

     /ASM

     Interrupts enable

}

 

Who would have thought that this wasn't an incredibly straight forward thing to do? Would you rather be happy or right?

 

That's the sync function... then there will be a 2nd function to update the WS2812B... Oh god help me!

<º))))><

I am only one lab accident away from becoming a super villain.

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

Still no idea what it is you are trying to achieve or what is not easy about it. Because of Linux, GCC must surely be the most widely used C/C++ compiler in the world so it's not like there isn't a wealth of info about how to use it readily available.

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

Dren wrote:
I just want to use studio to do everything 'in the project structure' do you understand what I mean by that?

As noted in #2, Atmel studio (being based on MS Visual Studio) has no problem with mixed-language projects.

 

Top hit for just googling, "atmel studio mix assembler":

APPLICATION NOTE Atmel AT1886:

Mixing Assembly and C with AVRGCC 8-bit Atmel Microcontrollers 

 

Features

Easily mix C and assembly source in Atmel® Studio 6

• C can call assembly routines

• Assembly can call C functions

• Passes variables and pointers between C and assembly

• Allows C and assembly to share global variables 

 

http://ww1.microchip.com/downloads/en/appnotes/doc42055.pdf

 

Dren wrote:
I have added a Blahblah.S file containing assembler into the project, but it spawns a host of errors....

Go on, then - what errors, exactly?

 

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: Sat. Aug 25, 2018 - 10:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Because of Linux, GCC must surely be the most widely used C/C++ compiler in the world so it's not like there isn't a wealth of info about how to use it readily available

Doxygen is also very widely used - I would think there's quite a good chance that someone has published a way to use it with Assembler source ... ?

 

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: Thank you for the link.

 

Yes, Doxygen can work on ASM files, it just 'screws up' the format/information a bit compared to C files.

 

clawson: I am sorry, but I do not know how to explain what I am trying to achieve any clearer to you in a short post, but thank you for your time/effort.

 

I just need some time to work through the errors and debug them. Hopefully I'll get back on the code later this week, ah well, stranger things have happened?

 

I work as a design consultant so software is just a tiny part of my work, maybe I should be happy that at my level it is still ANY part of my job? :)

 

 

 

 

 

<º))))><

I am only one lab accident away from becoming a super villain.

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

or maybe you should find a development consultant to help you ... ?

 

cheeky

 

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

Ah if only I could afford one!

 

Maybe I can hire a development Engineer? 

<º))))><

I am only one lab accident away from becoming a super villain.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well some great news, it's all working :) I came back to work last night after gym for a blissful hour with no distractions!

 

1) I created an ASM file (.S) :

      #define __SFR_OFFSET 0

      #include <avr/io.h>

      .global WS2812Bdriver

      WS2812Bdriver:

            (perfectly presentable assembler code)>>

      ret

 

2) A header file for the LED routines (.h)

       void WS2812Bupdate(void);

 

3) A file containing the 'C' code

      void WS2812Bupdate(void)

      {      WS2812Bdriver(LEDbuffer, sizeof(LEDbuffer));

              return;

      }

 

Then in 'main' I just call:

      WS2812Bupdate();

 

I do know that I do not need to make the function and I could call the ASM from 'main' directly, but by doing it this way Doxygen works much 'better' :) (or rather does what I want)

 

I had to write ASM for the low level control of the WS2812Bs as the MPU runs at 16MHz, but it was excellent to have the 8MHz example, thanks so much for that help.

 

It is up and running and I have a strip of >100 LEDs lighting up and giving me little dots in my vision! I'm really impressed by them, the colours are intense and they are so bright (this is the cause of my little dots!).

 

This is going to seem like magic to the company, currently they have so many problems with LEDs not meeting the required colours. They have been trying different brands and batches. Also changing resistors on the PCBs! I just need to link a couple of commands into the debug port and we can tweak them remotely, excellent.

 

 

 

<º))))><

I am only one lab accident away from becoming a super villain.

Pages