Interfacing BackPack _LCDpcf8574 with atmga32a

Go To Last Post
33 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to interface a BackPack_LCDpcf8574 with atmega32a in Atmel Studio environment.

I use an internal clock of 8 mhz.,and use this code:

/*
lcdpcf8574 lib sample

copyright (c) Davide Gironi, 2013

Released under GPLv3.
Please refer to LICENSE file for licensing information.
*/


#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <util/delay.h>

#include "lcdpcf8574/lcdpcf8574.h"

#define UART_BAUD_RATE 2400
#include "uart/uart.h"


#define PIN(C) (*(&C - 2))    /* address of input register of port x */


int main(void)
{
	//init uart
	uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );

    sei();

    uart_puts("starting...");

    //init lcd
    lcd_init(LCD_DISP_ON_BLINK);

    //lcd go home
    lcd_home();

    uint8_t led = 0;
    lcd_led(led); //set led

    while(1) {
    	lcd_led(led); //set led
    	led = !led; //invert led for next loop

    	//test loop
    	int i = 0;
    	int line = 0;
    	for(i=0; i<10; i++) {
    		char buf[10];
    		itoa(i, buf, 10);
    		lcd_gotoxy(1, line);
    		lcd_puts("i= ");
    		itoa(i, buf, 10);
    		lcd_gotoxy(4, line);
    		lcd_puts(buf);
    		line++;
    		line %= 2;
        	uart_puts(buf);
        	uart_puts("\r\n");
    		_delay_ms(100);
    	}
    }
}


It compiles  ok , but when I build the program , shows this error:

 

Severity    Code    Description    Project    File    Line
Error        ld returned 1 exit status    lcdpcf8574    collect2.exe    0

Severity    Code    Description    Project    File    Line
Error        recipe for target 'lcdpcf8574.elf' failed  

 

Any help would be appreciated.
 

This topic has a solution.
Last Edited: Wed. May 6, 2020 - 12:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
 8 mhz

milli hertz? that's really slow!

 

You mean 8 MHz - of course?

 

azizollah wrote:
It compiles  ok , but when I build the program , shows this error

That's just the summary saying, "something went wrong"

 

The details of the actual error(s) were before that. You need to copy & paste the comlpete output.

 

Post as for source code (Tip #1 in my signature, below)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the out put file:

 

------ Build started: Project: lcdpcf8574, Configuration: Release AVR ------
Build started.
Project "lcdpcf8574.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "E:\Atmel\7.0\Vs\Compiler.targets" from project "e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\lcdpcf8574.cproj" (target "Build" depends on it):
    Using "RunCompilerTask" task from assembly "E:\Atmel\7.0\Extensions\Application\AvrGCC.dll".
    Task "RunCompilerTask"
        Shell Utils Path E:\AtmelStudio\7.0\AZ108B.Projects
        E:\Atmel\7.0\shellUtils\make.exe all --jobs 4 --output-sync 
        Building target: lcdpcf8574.elf
        Invoking: AVR/GNU Linker : 5.4.0
        "E:\Atmel\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o lcdpcf8574.elf  main.o   -Wl,-Map="lcdpcf8574.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega32a -B "E:\Atmel\7.0\Packs\Atmel\ATmega_DFP\1.4.351\gcc\dev\atmega32a"  
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\Makefile(106,1): error: recipe for target 'lcdpcf8574.elf' failed
        E:/Atmel/7.0/Packs/Atmel/ATmega_DFP/1.4.351/gcc/dev/atmega32a/avr5/crtatmega32a.o:../../../../crt1/gcrt1.S:314: undefined reference to `main'
collect2.exe(0,0): error: ld returned 1 exit status
        make: *** [lcdpcf8574.elf] Error 1
        The command exited with code 2.
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "lcdpcf8574.cproj" -- FAILED.
Done building project "lcdpcf8574.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the actual error:

E:/Atmel/7.0/Packs/Atmel/ATmega_DFP/1.4.351/gcc/dev/atmega32a/avr5/crtatmega32a.o:../../../../crt1/gcrt1.S:314: undefined reference to `main'

So the Linker could not find your definition of main().

 

Have you actually included your .c file in the project ?

 

If you've not used Atmel Studio before, there's a load of 'Getting Started' videos on the Microchip website:

 

https://www.microchip.com/mplab/avr-support/atmel-studio-7 - scroll down near the end of the page

 

You should study them, and practice with some of the provided examples to gain familiarity with the tools ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your help .I included the main.c file and also the all the include.h files but still it says can not find the file...

This is the out put file.:

 

Build started.
Project "lcdpcf8574.cproj" (Compile target(s)):
Target "Compile" in file "E:\Atmel\7.0\Vs\Compiler.targets" from project "e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\lcdpcf8574.cproj" (entry point):
    Task "RunCompilerTask"
        Shell Utils Path E:\AtmelStudio\7.0\AZ108B.Projects
        E:\Atmel\7.0\shellUtils\make.exe "main.o" 
        Building file: .././main.c
        Invoking: AVR/GNU C Compiler : 5.4.0
        "E:\Atmel\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DNDEBUG  -I"E:\Atmel\7.0\Packs\Atmel\ATmega_DFP\1.4.351\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=atmega32a -B "E:\Atmel\7.0\Packs\Atmel\ATmega_DFP\1.4.351\gcc\dev\atmega32a" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\main.c(19,24): error: lcdpcf8574.h: No such file or directory
        compilation terminated.
        make: *** [main.o] Error 1
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\Makefile(76,1): error: recipe for target 'main.o' failed
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "Compile" in project "lcdpcf8574.cproj" -- FAILED.
Done building project "lcdpcf8574.cproj" -- FAILED.

Build FAILED.
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:

Thank you for your help. I included the main.c file and also the all the include.h files but still it says can not find the file...

 

Do you mean that you '#included' your main.c or added it to the project?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, that's a completely different error!

 

e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\main.c(19,24): error: lcdpcf8574.h: No such file or directory

So it's telling you it can't find your header file.

 

Assuing it does actually exist on your computer, that means you haven't (correctly/completely) set the Include Paths:

 

https://www.avrfreaks.net/commen...

 

https://www.avrfreaks.net/commen...

 

azizollah wrote:
I included  ... all the include.h files but still it says can not find the file

There is no need to do that, and it doesn't help the compiler to find them

 

As noted in the linked post, this is all standard 'C' stuff - not specific to Atmel Studio or AVR

 

Have you viewed those videos ?

 

Here are some 'C' learning & reference materials for you:

 

http://blog.antronics.co.uk/2011/08/08/so-youre-thinking-of-starting-with-c/

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. May 5, 2020 - 08:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Added to the project

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


azizollah wrote:
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\main.c(19,24): error: lcdpcf8574.h: No such file or directory
Surely that one is even more obvious than the first (it even contains "error:"). The message says that on line 19 at column 24 of main.c there is a #include "lcdpcf8754" and during the build the compiler cannot find that file. I'm guessing you DO have that file somewhere but, by default, the compiler (actually the preprocessor) will only be looking in the same directory where main.c is located. So you have two possible solutions I guess. Either you copy that lcdpcf8574.h file so it's in the same directory as main.c or you need to tell the preprocessor where to look. You do that with -I or, in the case of AS7, in the project settings under "Gnu C/C++" there is a section called "Directories" that allows you to list directories that should be searched for .h files. Any entry you make there will be passed to the preprocessor as a -I

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
use this code:

/*
lcdpcf8574 lib sample

copyright (c) Davide Gironi, 2013

Released under GPLv3.
Please refer to LICENSE file for licensing information.
*/

 

Which appears to be from here: 

 

https://github.com/swharden/AVR-projects/tree/master/ATMega328%202017-03-19%20i2c%20LCD%20pressure%20sensor/src_i2cLCD_01_works/lcdpcf8574

 

Davide Gironi wrote:

This exists so people who are really motivated can poke around the code. It is extremely rough, and not really intended to be used for anything more than inspection/education.

 

For details, see the project page: https://www.swharden.com/wp/2017-04-29-precision-pressure-meter-project/

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Compiles ok ,no error,But when try to build these errors are out.

Now what do you say to these errors:

 

Severity    Code    Description    Project    File    Line
Error        ld returned 1 exit status    lcdpcf8574    collect2.exe    0
Error        recipe for target 'lcdpcf8574.elf' failed    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\Makefile    106
Error        undefined reference to `lcd_gotoxy'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_gotoxy'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_home'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_init'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_led'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_led'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_puts'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
Error        undefined reference to `lcd_puts'    lcdpcf8574    e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c    1
 

Last Edited: Tue. May 5, 2020 - 10:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's not from the 'Output' window, is it ?

 

Always use the 'Output' window - that's the one that give the full story.

 

"Undefined reference" means what it says - you have referred to those names (probably functions) without actually defining them.

 

Usually, this means that you have #included a header file which declares those functions, but have not added the .c source file(s) (or pre-built binary) which define them.

 

If you don't understand the difference between a declaration and a definition, see:  http://c-faq.com/decl/decldef.html

 

Again, this is standard stuff - nothing specific to Microchip, AVR or Atmel Studio - eg, see: https://devzone.nordicsemi.com/f...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. May 5, 2020 - 10:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Sir,

This is the out put:

------ Build started: Project: lcdpcf8574, Configuration: Release AVR ------
Build started.
Project "lcdpcf8574.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "E:\Atmel\7.0\Vs\Compiler.targets" from project "e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\lcdpcf8574.cproj" (target "Build" depends on it):
    Task "RunCompilerTask"
        Shell Utils Path E:\AtmelStudio\7.0\AZ108B.Projects
        E:\Atmel\7.0\shellUtils\make.exe all --jobs 4 --output-sync 
        Building target: lcdpcf8574.elf
        Invoking: AVR/GNU Linker : 5.4.0
        "E:\Atmel\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o lcdpcf8574.elf  main.o   -Wl,-Map="lcdpcf8574.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,-L"../../../../toolchain/avr8/avr8-gnu-toolchain/lib"  -Wl,--gc-sections -mmcu=atmega32a -B "E:\Atmel\7.0\Packs\Atmel\ATmega_DFP\1.4.351\gcc\dev\atmega32a"  
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\Makefile(106,1): error: recipe for target 'lcdpcf8574.elf' failed
        main.o: In function `main':
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_init'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_home'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_led'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_led'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_gotoxy'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_puts'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_gotoxy'
e:\atmelstudio\7.0\AZ108B.Projects\lcdpcf8574\lcdpcf8574\Release\main.c(1,1): error: undefined reference to `lcd_puts'
collect2.exe(0,0): error: ld returned 1 exit status
        make: *** [lcdpcf8574.elf] Error 1
        The command exited with code 2.
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "lcdpcf8574.cproj" -- FAILED.
Done building project "lcdpcf8574.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the zip file I use in this project ,may be I am using the file not in the right place

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're lucky that, in this case, there was sufficient information in the summary - but generally there isn't, and/or it's shuffled into an unhelpful order.

 

So the point is to get into the habit of using the 'Output' window. Especially when posting for help with errors.

 

The answer remains as in #12

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
may be I am using the file not in the right place

So what file(s) do you think should be providing those definitions?

 

Is that file in your Project ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes all those files are in that zip file but I have also attached  here for you to see.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
all those files are in that zip 

But are they in the Project ?

 

Having them present on your hard drive is necessary, but not sufficient.

 

As for your main.c in posts #4 and #5, they also have to be in the Project.

 

Have you done that?

 

Atmel Studio will only build (ie, compile, link, etc) what is listed in the Project.

 

EDIT

 

That Zip file does not contain any project at all!

 

Again, have you watched those videos on how to properly get started with Atmel Studio ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. May 6, 2020 - 08:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I have them in the project, or better say how can I include them or be sure that they are there?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
how can I include them or be sure that they are there?

That would be covered in the videos!

 

You really need to spend some time getting familiar with the basics of the tools before proceeding with this!

 

There's really no point continuing until you've done that.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I created an AS7.0 project with your source files.

My LCD has address 0x27.   So I had to edit lcdpcf8574.h

#define LCD_PCF8574_DEVICEID 7 //device id, addr = pcf8574 base addr + LCD_PCF8574_DEVICEID .kbv my 8574 is 0x27

Edit.  And pcf8574.h

#define PCF8574_MAXDEVICES 8 //max devices, depends on address (3 bit)

 

And the uart.c file is pretty elderly.   The ATmega32A was not invented.   And the old m32 defines are deprecated nowadays.

So I had to edit uart.c

#elif  defined(__AVR_ATmega8__)  || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
  || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) \
  || defined(__AVR_ATmega323__) || defined(__AVR_ATmega32A__) //.kbv
  /* ATmega with one USART */
 #define ATMEGA_USART
 #define UART0_RECEIVE_INTERRUPT   USART_RXC_vect   //.kbv SIG_UART_RECV
 #define UART0_TRANSMIT_INTERRUPT  USART_UDRE_vect  //.kbv SIG_UART_DATA

The Gironi code seems incredibly complicated.   But it does work.

Note that you have to specify the correct I2C address.

 

Most backpacks have the same pcf to lcd mapping i.e. RS, RW, E, BL, D4, D5, D6, D7

Note that there are backpacks with D4, D5, D6, D7, RS, RW, E, BL

And others with PCF8574A i.e. BASE_ADDRESS = 0x38

 

David.

Attachment(s): 

Last Edited: Wed. May 6, 2020 - 09:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I created an AS7.0 project with your source files. 

@ azizollah - you really need to learn to do that for yourself - this is fundamental, foundational stuff!

 

Again, there are plenty of videos & tutorials to show you how, and none of it is really special or unique to Atmel Studio - you will find that all IDEs are pretty similar, and the key concepts remain the same.

 

 

david.prentice wrote:
The Gironi code seems incredibly complicated. 

I think he admits that - see quote in #10

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to David and Awneil

I will obey your advise and would like to see any link for videos or document to see because Atmel videos are not very helpful to me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azizollah wrote:
 Atmel videos are not very helpful to me.

In what way(s), precisely?

 

It's hard to recommend alternatives if we don't know what you're struggling with.

 

Again, note that most of it is general - not specific to Microchip / AVR / Atmel Studio - so general tutorials can also be helpful.

 

As always when learning any new skill, start simple with the basics and build up in small steps.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you David,

Everything is fine and working.

I can only pray for you ,thats all I can do!

God Save David.

AAmeen.

Last Edited: Wed. May 6, 2020 - 12:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have not been following this thread.    Forgive me if I have missed this info:

 

1.  Which country?  UK, Germany, Egypt, ...

2.  What is your native language?  English, Urdu, ...

3.  What kind of PC?  e.g. Windows-7, Windows-8, Windows-10, Linux, Mac, ...

4.  Internet access?

 

You don't need to reveal any secrets but it helps readers to make appropriate replies.

e.g.  an AS7.0 project is no good for Linux

e.g.  no monster downloads if there is poor internet.

 

I would expect the AS7.0 project to work out of the box.   F_CPU was set to 8MHz in Project Properties,  AVR=ATmega32A

 

If the backlight is turning on and off every 3 seconds,  the program is working.

Adjust the contrast pot on the backpack.   It should be at 0R i.e. fully clockwise.

 

David.

 

Edit.  Oops.  I missed your last post.   Welcome to the Forum anyway.    And country and language would be useful for best replies.

Last Edited: Wed. May 6, 2020 - 01:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David,

You have made two projects for me one under the name of aziz_backpack and the other aziz_uno ,whats the reason for making two projects linked together?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I ran the aziz_uno on a 16MHz ATmega328P i.e. Uno board

 

Both projects share the same source code.   They are links to src folder.

Each project has different Properties e.g. MCU, F_CPU

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am a little late to teh party, and I only skimmed over the posts. 

 

I use this library from Davide Gironi:

 

http://davidegironi.blogspot.com...

 

It is based on Peter Fleurys excellent LCD library, and is super easy to use.

 

Might help someone in teh future.

 

Cheers,

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@East Cost Jim,

 

Aziz was using the exactly the same Girone ZIP that you linked to.

I did nothing more than create an AS7.0 solution and fix a few "features".

 

Of course it requires serious attention to the features.   The only concession in the ZIP was (uart.c):

#elif defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
 /* ATmega with one USART */
 #define ATMEGA_USART0
 #define UART0_RECEIVE_INTERRUPT   USART_RX_vect
 #define UART0_TRANSMIT_INTERRUPT  USART_UDRE_vect

Every other MCU has deprecated interrupt names.   Even mega168 and mega328 !!

It also uses 10kHz bus speed.   Which transforms the regular 37us HD44780 functions into 14400us operations.

 

Yes,  it works.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
It also uses 10kHz bus speed.

 

Gironi's library?  10KHz?  I have always used 100KHz......Crap, now I have to look...

 

david.prentice wrote:

Aziz was using the exactly the same Girone ZIP that you linked to.

I did nothing more than create an AS7.0 solution and fix a few "features".

 

I did say I only skimmed the posts, and I might have missed it if Davide's name was posted. 

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My apologies.   I typed Girone.

 

Yes,   Davide Gironi was mentioned in #1, #10.   Again in #21, #22.   You mentioned the library in #29, #31.  I mis-spelled in #30.

 

Speed is not very important in a 16x2.   But deprecated vector names need to be updated.

Bill Perry's HD44780 Arduino library is the most convenient way to use baclpacks  (or any Character LCD)

 

Aziz is using a mega32A which is not a standard Arduino target.    The Fleury I2C code is suitable.   But there are more efficient ways to drive the LCD via a PCF8574.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
But there are more efficient ways to drive the LCD via a PCF8574.

 

I have no doubt.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user