SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By arix
#119670
Hi,
I bought an LCD module to use it with . This module consists of a 2.8 tft lcd, a touch screen attached with controller, a camera and an atmega32L which manages all of them on the module and could be commanded from Arduino.

To start with it, I first backed up the code on it (from factory, a test, that when you turn the device on, it shows a hello world like message). So I started to compile the sample source code (that must be compiled to give the same hello world result) as a start point to learn. First small errors where easy to get rid of, but now I came to a point where I can't solve the error message (with the level of knowledge I have). I tried to compile the code in avrStudio 4 (it is unknown to me, with which compiler/IDE the seller prepared the code/hex that was supplied. I provide here the code and please if anybody has the time to help, have a look if you could understand the problem with it.

The error:
../int.c:16: error: 'GICR' undeclared (first use in this function)

But as long a s I know, the def. of this reg. is in general files of compiler, so why it bothers with it?

This is the original supplied sample code:
myedit_ATmega32_ili9331_ov7670.zip
This is my edit, still with minor changes of course:
orig_ATmega32_ili9331_ov7670.zip
I appreciate a lot your help!
You do not have the required permissions to view the files attached to this post.
By n1ist
#119681
Do you have the correct processor type defined in your makefile or in AVR Studio? It uses this to pull in the correct io_xxx.h file.
/mike
By arix
#119687
n1ist wrote:Do you have the correct processor type defined in your makefile or in AVR Studio? It uses this to pull in the correct io_xxx.h file.
/mike
Thank you for pointing me to the right direction. I've got some result, but one problem remained which I can't understand...I'll in minutes post the results...
By arix
#119693
arix wrote:
n1ist wrote:Do you have the correct processor type defined in your makefile or in AVR Studio? It uses this to pull in the correct io_xxx.h file.
/mike
I just rebuilt. I have got rid of lot of errors, but still 1 is remained that I can't solve. It says that 'change_reg' is defined in multiple places, while I can't agree with the compiler, as I can't find it defined in various places! This is my build log, if possible please help:
Code: Select all
Build started 8.2.2011 at 23:32:09
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT delay.o -MF dep/delay.o.d  -c  ../delay.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ILI9331.o -MF dep/ILI9331.o.d  -c  ../ILI9331.C
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT int.o -MF dep/int.o.d  -c  ../int.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d  -c  ../main.c
../main.c: In function 'main':
../main.c:26: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:27: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:29: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:33: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ov7660.o -MF dep/ov7660.o.d  -c  ../ov7660.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ov7660config.o -MF dep/ov7660config.o.d  -c  ../ov7660config.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT SCCB.o -MF dep/SCCB.o.d  -c  ../SCCB.c
avr-gcc -mmcu=atmega32 -Wl,-Map=main.map delay.o ILI9331.o int.o main.o ov7660.o ov7660config.o SCCB.o     -o main.elf
int.o: In function `delay_us':
C:\AVR_programmer\main\default/../delay.C:8: multiple definition of `delay_us'
delay.o:C:\AVR_programmer\main\default/../delay.c:8: first defined here
int.o: In function `delay_ms':
C:\AVR_programmer\main\default/../delay.C:14: multiple definition of `delay_ms'
delay.o:C:\AVR_programmer\main\default/../delay.c:14: first defined here
ov7660config.o:(.progmem.data+0x0): multiple definition of `change_reg'
ov7660.o:(.progmem.data+0x0): first defined here
make: *** [main.elf] Error 1
Build failed with 1 errors and 5 warnings...
By n1ist
#119751
It's hard to tell since I don't have all of the code...

It sounds like you have two modules int.c and delay.C that both have functions delay_us() and delay_ms(). I'd switch int.c to use _delay_ms() and _delay_us() that are defined in <util/delay.h> in the AVR GCC distribution, and remove delay.C.

It sounds like change_reg is defined in both ov7660config.c and ov7660.c. Should they be defined static so they are only visible within their own file? Should only one of those be included? It could also be that it is defined in a .h included by both of those; in that case you may have to play with defining it extern.

As for the "warning: pointer targets in passing argument 3 f 'LCD_write_english_string' differ in signedness" warning, that's probably an issue with char* vs. unsigned char *. They are just warnings, and I'd ignore those for now.
/mike
By arix
#119775
n1ist wrote:It's hard to tell since I don't have all of the code...

It sounds like you have two modules int.c and delay.C that both have functions delay_us() and delay_ms(). I'd switch int.c to use _delay_ms() and _delay_us() that are defined in <util/delay.h> in the AVR GCC distribution, and remove delay.C.

It sounds like change_reg is defined in both ov7660config.c and ov7660.c. Should they be defined static so they are only visible within their own file? Should only one of those be included? It could also be that it is defined in a .h included by both of those; in that case you may have to play with defining it extern.

As for the "warning: pointer targets in passing argument 3 f 'LCD_write_english_string' differ in signedness" warning, that's probably an issue with char* vs. unsigned char *. They are just warnings, and I'd ignore those for now.
/mike
Thank you! but I uploaded all the code I have, may be any archive is broken?

I don't see any double-definition of delay functions there :(

Still turning around myself...please help!
By arix
#119777
I double checked: there the delay_us/_ms is neither defined nor used in non of init.c and init.h.

Please if you can have a look at code I uploaded...I can't figure it out, turning on my place :(

p.s. code is not mine, it is Chinese code supplied as sample with the LCD module I bought, no kind of support, also commented in Chinese (well, Google will translate it). I have not the level of knowledge with which this code is written, but I can over come it with the help you forum...or at least I hope this to happen :D
By n1ist
#119861
I took the original code and made the following changes:

- inFAT.h, change the prototype for FAT_Init() to
unsigned char FAT_Init(void);

- in mmc_sd.h, remove the extra trailing slash from #include "config.h"
- in mmc_sd.h, change prototype for MMC_SD_ReadCapacity() to
extern uint32 MMC_SD_ReadCapacity(void);

- in main.c, #include "mmc_sd.h"
- remove ov7670config.c from the project. It is already included in ov7670.c (which is a poor thing to do...)

Bugs that need to be fixed:
- in main.c disp_image(), there are some uninitialized variables
- delay.c is totally bogus and will get optimized away. Replace it with code
that calls _delay_us() or _delay_ms(), remembering that both of those need CONSTANT arguments
- I'm sure there are others, but those jumped right out at me.

In general, this code is rather buggy and has a number of issues that need to be cleaned up. However, I don't get any of the duplicate definitions that you are getting. I am using avr-gcc (WinAVR 20100110) 4.3.3
/mike
By arix
#119870
Mike! Many thanks!

I finally build it with success! I got 7 warnings, but at least no error, some progress started!

I first got read of memory card files at all to differentiate to something simpler. Next, replaced delay_ms/_us everywhere with _delay_ms/_us.

Next I opened eXtreme burner to burn the generated hex file to the module. It complained: "this hex file is too large for the chosen MCU". Well but, in avrStudio 4 I chose atmega32L and 16000hz as it is on my board!

Even though it complained, it burnt the hex into the module. Unfortunately when I restarted the module, the hello world message type that is the function of the whole code, didn't appear. The LCD remains as if not turned on. I don't suppose that the supplied hex file is a cheat (i.e. Chinese supplied a source code but hex is from another program).

Could it be the reason that this board exactly should use a custom delay_ms/_us, than the standard lib one please?
By n1ist
#119887
No, their delay routine is just bogus.

If you edited all of the files to change the delay_xx to _delay_xx, did you also remove the #include <delay.C>" from lcd.c?

I just deleted delay.c and replaced delay.h with
Code: Select all
#include <util/delay.h>
#define delay_us _delay_us
#define delay_ms _delay_ms
I am building this directly under Programmer's Notebook (just using make all). If you are building under AVR Studio, did you select the correct processor (under Project->Configuration Options) ?

When I build it, it's 10K long, which should easily fit in an ATMega32
By arix
#119890
n1ist wrote:No, their delay routine is just bogus.

If you edited all of the files to change the delay_xx to _delay_xx, did you also remove the #include <delay.C>" from lcd.c?

I just deleted delay.c and replaced delay.h with
Code: Select all
#include <util/delay.h>
#define delay_us _delay_us
#define delay_ms _delay_ms
I am building this directly under Programmer's Notebook (just using make all). If you are building under AVR Studio, did you select the correct processor (under Project->Configuration Options) ?

When I build it, it's 10K long, which should easily fit in an ATMega32
well in Project->Configuration I have atmega32 selected and 16000hz freq. is there. I guess I have some debug info somewhere added, is it possible to turn off debug info in avrStudio?

My hex size is 139kB !!!

My build report:
Code: Select all
Build started 10.2.2011 at 20:53:42
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT delay.o -MF dep/delay.o.d  -c  ../delay.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ILI9331.o -MF dep/ILI9331.o.d  -c  ../ILI9331.C
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT int.o -MF dep/int.o.d  -c  ../int.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d  -c  ../main.c
../main.c: In function 'main':
../main.c:34: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:35: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:37: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
../main.c:42: warning: pointer targets in passing argument 3 of 'LCD_write_english_string' differ in signedness
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ov7660.o -MF dep/ov7660.o.d  -c  ../ov7660.c
avr-gcc  -mmcu=atmega32 -Wall -gdwarf-2 -std=gnu99       -DF_CPU=16000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT SCCB.o -MF dep/SCCB.o.d  -c  ../SCCB.c
../SCCB.c: In function 'startSCCB':
../SCCB.c:39: warning: implicit declaration of function 'urdelay_ms'
avr-gcc -mmcu=atmega32 -Wl,-Map=main.map delay.o ILI9331.o int.o main.o ov7660.o SCCB.o     -o main.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  main.elf main.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex main.elf main.eep || exit 0
avr-objdump -h -S main.elf > main.lss

AVR Memory Usage
----------------
Device: atmega32

Program:   50946 bytes (155.5% Full)
(.text + .data + .bootloader)

Data:      22837 bytes (1115.1% Full)
(.data + .bss + .noinit)


Build succeeded with 6 Warnings...
By n1ist
#119896
It looks like we have been building two different things since the Makefile (what I was using) and the AVR Studio project are different.

- The size of the hex file itself isn't important. The size reported as memory usage at the end of the listing shows that you are trying to put 55K of stuff in a 32K bag, so it's no surprise that it doesn't fit...

- Remove delay.o from your project as you don't want to link with it anymore
- Rename the file ILI9331.C to ILI9331.c. Likewise ILI9331.H to ILI9331.h It does make a difference.
- Remove ov7660config.c from your project as ov7660.c includes it.
- Add FAT.c and mmc_sd.c to the project

What crystal is actually on the board? You mention 16MHz but the makefile builds it for 8MHz...

I was able to get it to build, and it just barely fits... This code is really a mess. I have attached the hex file that I have generated. Just rename it back to main.hex
/mike
You do not have the required permissions to view the files attached to this post.
By arix
#119952
>What crystal is actually on the board?
Really 16.000hz I checked it first time I was going to state in avrStudio, as I knew that Chinese may not have time to update their code when production changes! :-)

Thank you Mike, I really appreciate your kind help! My module now works with the code I compiled and burnt.

Now I can start to read a nice book I have on AVR MCU and factorize this code out to some cleaner one, but at least I know I have a working LCD driver, which was up to now the greatest mystery to me, being a newbie (started from Arduino).

So many thanks for the time you put to help and support me, and many thanks to the SparkFun that created the channel by which I could ask for your help.
:mrgreen:
By magicmarcus
#133758
Hello!
I bought this same camera with the kit.
After this try atemga644 program (because as I have), and unfortunately does not work.
I ask for the code, so that I can read such address 0x0B and view the registry value via USART.
Please help.
PS. I have a variety of cameras on the 3V3. Only if the ports are also 3V3?
I greet and thank
Marek