I managed to port my graphics library for the attiny 85 to arduino

i will try if i can add embedded c projects...
i actually did benchmarks for a atmega328, simulated with the mircochip studio emulator (which is directly build from the cpu-vhdl and should be cycle exact)

the cycle numbers are allways the multiplication and then the assignment to the port, so they are 1 multiplication and 1 conversion to unsigned char:

#include <stdfix.h>
#include <avr/io.h>


int main(void)
{
	float a=0.2;  // 32 bit foat
	accum b=0.2;  // 32 bit s15.16 fixed
	short accum c=0.2;  // 16bit s7.8 fixed

    while (1) 
    {
		a=a*a;  // start:32
		PORTB=a;  // end: 205  -> 173 cycles
		b=b*b;  // start:205
		PORTB=b; // 327        -> 122 cycles
		c=c*c;   // start:327
		PORTB=c; // end:399    -> 72 cycles
		
    }
}

i mainy work with mircochip studio, i am a little bit clueless when it comes to the arduino ide.

1 Like

and you are 100% correct, it really works....i allways tried to somehow write the whole sketch in c....i feel stupid....i will try to port a dos 3d engine in c to the avr-gcc fixed point....:


image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.