I need to initialize i/o ports very soon after powerup, so I need to execute some assembler instructions before the c stack initialization takes over.
How can I link some assembler with the other files to create the hex, thus avoiding editing the lss file and going from there every time I make a build?
'very soon' meaning the first instructions executed after the reset should be mine and not C's. Right now it takes ~4300 clock cycles before the first C statement is executed, because all the variables are loaded from program memory into ram before main starts, and this is too slow for me.
Ok I found that the 0.5ms for the C init wasn´t the biggest problem, the default setting of 16K cycles + 65ms startup delay was much worse.
Still, is there a way in avr-gcc to do what I intended?
Not sure why you need to drop into asm to init the ports but
historically the startup file is named c0.c and most often already has some ASM in in it. Just edit it.
On another note hardware should be designed so that it come up in a safe state. You may want to examine why you need to do the init so early after power up.
Clock is 8MHz internal osc, I din' t measure it I simulated the number of cycles needed. The startup time was set by fuses.
3v0: yes now I know I should have put there some pullups the to make sure it does what I intend to on startup, but it's a little too late since I already made the boards.
I couldn't find any file called c0.c in win-avr installation, or any .c apart from examples.
kubeek you can always tack on pullups just use full lead length resitor trim and jumper them to the appropropiate pins. Half or more of all electronics use this after the fact or intentional addition of a fly lead layer to electronics devices to save time and money in facilities that can't do the proper number of layers or routed vias.
3v0: yes now I know I should have put there some pullups the to make sure it does what I intend to on startup, but it's a little too late since I already made the boards.
I couldn't find any file called c0.c in win-avr installation, or any .c apart from examples.
Ok I found that the 0.5ms for the C init wasn´t the biggest problem, the default setting of 16K cycles + 65ms startup delay was much worse.
Still, is there a way in avr-gcc to do what I intended?