abeltomillo:
seems the pin state changes before I can get the proper value because baudrate is too high.
is there an easy way of starting to code some C/ASM for AVRs?
thanks,
cheers.
You should read the answers you get. Larry told you exactly what's wrong.
You can't use Serial methods inside an interrupt routine. Save the value to a global variable, set a global BOOL data_available that tells your program something is available for printing, and then write code in your loop() function that checks data_available and does a Serial.println() if data IS available (and clears the flag after printing.)
abeltomillo:
really interesting that about "volatile" variables. what's about volatile asm inline code?
that array is going to crash, that's it haha... just making a test
thanks,
cheers.
Volatile has no meaning in ASM code. Volatile tells the C compiler that a variable's value can change in unexpected ways, so don't keep it in a register.
Imagine that the compiler decides to optimize by ignoring the value of a variable in memory and use a register instead. Then an interrupt routine comes along and changes the value in memory. When the interrupt returns, the program keeps reading and writing to the register, and the change made by the interrupt routine is completely missed.
With ASM, you explicitly control what's stored in fixed memory locations, what's saved on the stack, what's written to flash memory, and what's done in registers. The compiler doesn't make those decisions for you.