I'm trying to set up an ILI9341 tft for a project that won't be using the arduino framework (partially for learning purposes - I already have the ILI9341 working with an arduino and realize that I could just follow the path of least resistance and use an arduino for this).
Initially I tried to go towards just making something arduino-esque by taking the working libraries and porting them to something a non-arduino avr could run. Then I realized that a lot of the SPI and TFT display libraries I was using depended on the whole arduino framework and tabled that approach.
Now I am attempting to switch to a premade ILI9341 library for AVR that I found here: https://community.atmel.com/proj... (I will be discussing my attempts at using this code from now on).
I made a few modifications for my purposes:
1)modified the cs/dc/mosi/miso/sck/ss pins to work for my setup
2) changed the last line of ili9341_spi_init from "PORTB |=(1<<1);//cs off during startup" to "controlport|=(1<<cs);//cs off during startup"
3) made ili9341_putchar_printf return 0 (printf success) at the end since it specifies a return type.
Even with these changes the library is a bit busted, for the ATmega1284p at least. I am getting freezes/resets midway through the display_init function currently. The screen will be cleared to black and then the program will freeze/reset some distance through printing the first line ("mode - constant voltage"). The screen clear and printout of characters (color, appearance) is good in and of itself, so I think this means the hardware interface is working well enough.
I've had trouble narrowing this down due to the nature of the issue but the SPI write function (ili9341_spi_send) seems to be the root cause of the problem. Sometimes freezes will happen in the wait ("while(!(SPSR & (1<<SPIF)));//wait till the transmission is finished"). The resets seem to be coming from something else entirely though, and I can't account for those.
I've tried making modifications to the file but the freezes plus the resets make it hard to get anything stable. I'd like some high-level advice to direct my attempts at fixing this if possible. The problem seems to have characteristics of a stack overflow but I doubt this is the case given the sram size of the micro I'm using. It might also be a random jump out somewhere in memory, but I'm not sure where that would be happening in the code. What other kind of issue could this be?