Waiting for some chips to come I started writing my first program using Atmel Studio. I used a Arduino Nano that has the same chip to test. I grabbed from the internet a LCD library by David Gironi to setup a 2x16 LCD. Screen worked perfectly on the Arduino. Friday I got the actual chips 328Ps and set them up on the breadboard, using the same 16Mhz clock that the Arduino uses. Loaded the program and everything was slow, changed the fuses for a 8Mhz with no divide by 8. To test I have a LED that blinks every second triggered by an interrupt that shows me that the program is working, and it is blinking at that rate.
My problem is that the LCD now misses letters and the positioning randomly is in the wrong place. So probably the problem is generated on the LCD library and some of the problem is that there are instructions beyond my understanding such as this one:
static inline void _delayFourCycles(unsigned int __count)
{
if ( __count == 0 )
__asm__ __volatile__( "rjmp 1f\n 1:" ); // 2 cycles
else
__asm__ __volatile__ (
"1: sbiw %0,1" "\n\t"
"brne 1b" // 4 cycles/loop
: "=w" (__count)
: "0" (__count)
);
}
Now, I'm not sure if when I was using the Nano, it was using the external clock, it may have been using the internal clock. At a much slower clock the LCD has enough time to react.
Is there another LCD using I2C library somewhere.