Posted by JohanEkdahl: Fri. Mar 20, 2009 - 12:04 PM
1
2
3
4
5
Total votes: 0
Maybe he fails to realize that this is page 3 of the thread...
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
Posted by JohanEkdahl: Wed. Mar 25, 2009 - 11:51 AM
1
2
3
4
5
Total votes: 0
You need both .c and .h files. The question reveals that your knowledge of the C programming language is close to none. You should get a good book on C and start reading.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
these are the error that my avr show when i build that code
Quote:
Build started 25.3.2009 at 23:37:15
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -O0 -MD -MP -MT demo1.o -MF dep/demo1.o.d -c ../demo1.c
../demo1.c:2:24: error: LCD_Driver.h: No such file or directory
../demo1.c:5: error: 'LCD_TEXTBUFFER_SIZE' undeclared here (not in a function)
../demo1.c:5: error: 'LCD_DISPLAY_SIZE' undeclared here (not in a function)
../demo1.c:5: error: empty scalar initializer
../demo1.c:5: error: (near initialization for 'TextBuffer')
../demo1.c:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'StrStart'
../demo1.c:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'StrEnd'
../demo1.c:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScrollCount'
../demo1.c:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'UpdateDisplay'
../demo1.c:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ShowColons'
../demo1.c:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScrollFlags'
../demo1.c:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'LCD_SegTable'
../demo1.c: In function 'LCD_Init':
../demo1.c:82: warning: implicit declaration of function 'LCD_CONTRAST_LEVEL'
../demo1.c:85: error: 'LCDCRB' undeclared (first use in this function)
../demo1.c:85: error: (Each undeclared identifier is reported only once
../demo1.c:85: error: for each function it appears in.)
../demo1.c:85: error: 'LCDCS' undeclared (first use in this function)
../demo1.c:85: error: 'LCDMUX0' undeclared (first use in this function)
../demo1.c:85: error: 'LCDPM0' undeclared (first use in this function)
../demo1.c:88: error: 'LCDFRR' undeclared (first use in this function)
../demo1.c:88: error: 'LCDPS0' undeclared (first use in this function)
../demo1.c:88: error: 'LCDCD0' undeclared (first use in this function)
../demo1.c:91: error: 'LCDCRA' undeclared (first use in this function)
../demo1.c:91: error: 'LCDEN' undeclared (first use in this function)
../demo1.c:91: error: 'LCDAB' undeclared (first use in this function)
../demo1.c:91: error: 'LCDIE' undeclared (first use in this function)
../demo1.c: In function 'LCD_puts_f':
../demo1.c:107: warning: implicit declaration of function 'strcpy_P'
../demo1.c:108: warning: implicit declaration of function 'LCD_puts'
../demo1.c: At top level:
../demo1.c:118: warning: conflicting types for 'LCD_puts'
../demo1.c:108: warning: previous implicit declaration of 'LCD_puts' was here
../demo1.c: In function 'LCD_puts':
../demo1.c:119: error: 'uint8_t' undeclared (first use in this function)
../demo1.c:119: error: expected ';' before 'LoadB'
../demo1.c:120: error: expected ';' before 'CurrByte'
../demo1.c:124: error: 'CurrByte' undeclared (first use in this function)
../demo1.c:131: error: 'LoadB' undeclared (first use in this function)
../demo1.c:136: error: 'LCD_SPACE_OR_INVALID_CHAR' undeclared (first use in this function)
../demo1.c:141: error: 'ScrollFlags' undeclared (first use in this function)
../demo1.c:141: error: 'LCD_FLAG_SCROLL' undeclared (first use in this function)
../demo1.c:143: error: expected ';' before 'Nulls'
../demo1.c:143: error: 'Nulls' undeclared (first use in this function)
../demo1.c:148: error: 'StrStart' undeclared (first use in this function)
../demo1.c:149: error: 'StrEnd' undeclared (first use in this function)
../demo1.c:150: error: 'ScrollCount' undeclared (first use in this function)
../demo1.c:150: error: 'LCD_SCROLLCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:150: error: 'LCD_DELAYCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:151: error: 'UpdateDisplay' undeclared (first use in this function)
../demo1.c:151: error: 'true' undeclared (first use in this function)
../demo1.c: At top level:
../demo1.c:161: warning: return type defaults to 'int'
../demo1.c: In function 'ISR':
../demo1.c:162: error: 'ScrollFlags' undeclared (first use in this function)
../demo1.c:162: error: 'LCD_FLAG_SCROLL' undeclared (first use in this function)
../demo1.c:164: error: 'ScrollCount' undeclared (first use in this function)
../demo1.c:166: error: 'UpdateDisplay' undeclared (first use in this function)
../demo1.c:166: error: 'true' undeclared (first use in this function)
../demo1.c:167: error: 'LCD_SCROLLCOUNT_DEFAULT' undeclared (first use in this function)
../demo1.c:173: error: 'uint8_t' undeclared (first use in this function)
../demo1.c:173: error: expected ';' before 'Character'
../demo1.c:173: error: 'Character' undeclared (first use in this function)
../demo1.c:175: error: expected ';' before 'Byte'
../demo1.c:177: error: 'Byte' undeclared (first use in this function)
../demo1.c:177: error: 'StrEnd' undeclared (first use in this function)
../demo1.c:180: warning: implicit declaration of function 'LCD_WriteChar'
../demo1.c:183: error: 'StrStart' undeclared (first use in this function)
../demo1.c:184: error: 'LCD_FLAG_SCROLL_DONE' undeclared (first use in this function)
../demo1.c:189: error: 'ShowColons' undeclared (first use in this function)
../demo1.c:190: error: expected expression before ')' token
../demo1.c:190: error: 'LCD_LCDREGS_START' undeclared (first use in this function)
../demo1.c:192: error: expected expression before ')' token
../demo1.c:194: error: 'false' undeclared (first use in this function)
../demo1.c:196: warning: control reaches end of non-void function
../demo1.c: At top level:
../demo1.c:204: warning: type defaults to 'int' in declaration of 'uint8_t'
../demo1.c:204: error: expected ';', ',' or ')' before 'Byte'
../demo1.c:232: warning: type defaults to 'int' in declaration of 'uint8_t'
../demo1.c:232: error: expected ';', ',' or ')' before 'ColonsOn'
In file included from ../demo1.c:253:
c:/winavr/bin/../avr/include/avr/pgmspace.h:857: error: conflicting types for 'strcpy_P'
../demo1.c:107: error: previous implicit declaration of 'strcpy_P' was here
../demo1.c:283: warning: conflicting types for 'LCD_WriteChar'
../demo1.c:283: error: static declaration of 'LCD_WriteChar' follows non-static declaration
../demo1.c:180: error: previous implicit declaration of 'LCD_WriteChar' was here
make: *** [demo1.o] Error 1
Build failed with 67 errors and 11 warnings...
You go to the first post in this thread. You select all the text under LCD_Driver.c you copy it, you create a blank file called LCD_Driver.c and paste it in then save it. You then do the same with the text under LCD_Driver.h and save that to LCD_Driver.h. You make sure these two files are in the same directory as your other project files. In one of your own .c files where you plan to use functions in LCD_Driver.c you simply add the line:
#include "LCD_Driver.h"
Then in the list of files to be built in the project you add LCD-Driver.c to the list. Now build the project and it should all just work.
Posted by smileymicros: Wed. Mar 25, 2009 - 05:47 PM
1
2
3
4
5
Total votes: 0
Make sure that a copy of both the .c and the .h file are in the directory used by your AVRStudio project. In the AVR GCC directory tree on the left of AVRStudio click on 'Source Files' and 'Add Existing File(s)' to add the .c file, then in the 'Header Files' also use 'Add Existing File(s)' to add the .h file. Now when you click Compile AVRStudio should be able to find both files.
i follow what you ask me to do and i can build it.
but the prob is the program shows warning there
Quote:
rm -rf fyp.o fyp.elf dep/* fyp.hex fyp.eep
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT fyp.o -MF dep/fyp.o.d -c ../fyp.c
In file included from ../fyp.c:2: ../LCD_Driver.h:48:8: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT LCD_Driver.o -MF dep/LCD_Driver.o.d -c ../LCD_Driver.c
In file included from ../LCD_Driver.c:21: ../LCD_Driver.h:48:8: warning: no newline at end of file
../LCD_Driver.c:255:3: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 fyp.o LCD_Driver.o -lm -o fyp.elf
avr-objcopy -O ihex -R .eeprom fyp.elf fyp.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex fyp.elf fyp.eep || exit 0
c:\WinAVR\bin\avr-objcopy.exe: there are no sections to be copied!
Posted by JohanEkdahl: Thu. Mar 26, 2009 - 05:26 PM
1
2
3
4
5
Total votes: 0
Quote:
what the problem with that warning
The problem is exactly what the warning says. There is no newline at the end of the file. How can that be unclear?
IIRC this can be a problem for the some compilers (not seeing the last token in the file). The simple remedy is to edit those files. Go to the last line. Place the caret after that last character on the line. Hit enter. Save the file and exit. Repeat for all files that generate the warning.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
i follow what you ask me to do and i can build it.
but the prob is the program shows warning there
Quote:
rm -rf fyp.o fyp.elf dep/* fyp.hex fyp.eep
Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT fyp.o -MF dep/fyp.o.d -c ../fyp.c
In file included from ../fyp.c:2: ../LCD_Driver.h:48:8: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 -Wall -gdwarf-2 -DF_CPU=1000000UL -O0 -fsigned-char -std=gnu99 -MD -MP -MT LCD_Driver.o -MF dep/LCD_Driver.o.d -c ../LCD_Driver.c
In file included from ../LCD_Driver.c:21: ../LCD_Driver.h:48:8: warning: no newline at end of file
../LCD_Driver.c:255:3: warning: no newline at end of file
avr-gcc.exe -mmcu=atmega169 fyp.o LCD_Driver.o -lm -o fyp.elf
avr-objcopy -O ihex -R .eeprom fyp.elf fyp.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex fyp.elf fyp.eep || exit 0
c:\WinAVR\bin\avr-objcopy.exe: there are no sections to be copied!
Hye,
I have compile both keypad and lcd butterfly code C in a AVR Studio without warning and error.
But after i downloaded to AVR there was a buzzing sound appear.
Why is it happened?? Is it my coding mistake or AVR problem?
I attach the code for reference. Hope someone can help.. :cry:
Posted by smileymicros: Mon. Mar 30, 2009 - 07:28 PM
1
2
3
4
5
Total votes: 0
Look at the Butterfly schematic to see which pin is attached to the piezo element (buzzer) then note which part of you code is toggling that pin at an audio frequency.
Posted by smileymicros: Sat. Apr 4, 2009 - 04:22 PM
1
2
3
4
5
Total votes: 0
I must be misunderstanding your question since both the Butterfly schematics and the 'Butterfly Alternate Pin Uses' document that I provided a link to for you both show that PORTD is connected to the PORTD pad AND to 8 of the LCD pins - so as one should see on the schematic or read in the document, you cannot use PORTD for both the LCD and as an input port at the same time.
And I just looked at your code and now my question is: what function in your code is sending data to the LCD? Earlier you said you changed your keypad from PORTB to PORTD and the buzzing stopped, but your code doesn't show this. Were you trying to turn on individual LCD elements with the write to PORTD?
And looking further back, I see that Dean suggested you use his LCD driver, so now I'm even more confused about what you are asking.
Please answer:
1. Did you try to use Dean's driver?
2. If so, why doe's it not show up in you code listing?
3. If you read the Butterfly Schematics how could you not know that your code would cause the Piezo element to buzz?
4. You said that after you changed ports the buzzing stopped, but you show the same code unchanged?
4. And if you read the Schematics and the Alternate Pin Use document, how could you not know that moving the keypad to PORTD would interfere with the LCD?
Again, I must be missing something in your question.
oh sorry..
i didn't mention it to you before..
after read the schematic i know that the Piezo element is in PINB5.
It's true that in the early i try to connect my keypad to PORTD but after reading the schematic, i change it back to PORTB because i realize PORTD will interfere the LCD.
my answer for your question..
1. yes, i 'm using dean's driver.
2. i send you the full code of my program include Dean's driver.
3. i already ask my friends.they said maybe the connection from the keypad to butterfly makes the buzzing sound.
your question 4 and 5 i already explain at above
sorry again because sending you the not update program
Posted by smileymicros: Sun. Apr 5, 2009 - 04:08 PM
1
2
3
4
5
Total votes: 0
Your keypad.c code:
#include
#include "LCD_Driver.h"
int main()
{
//high nibble for output(columns) low for input(rows);
DDRD=0xF0;
//enable internal pullups for PB0-PB3
PORTD=0x0F;
//Port D for indication only
DDRB=0xFF;
while (1) //loop key check forever
{
//first column
PORTD =0b01111111;
//check for rows and send key number to portD
//instead sending key number to PORTD you can use
// any function that serves pressed button
if (bit_is_set(PIND, 3)) PORTB=1;
if (bit_is_set(PIND, 2)) PORTB=2;
if (bit_is_set(PIND, 1)) PORTB=3;
if (bit_is_set(PIND, 0)) PORTB=4;
//second column
PORTD =0b10111111;
if (bit_is_set(PIND, 3)) PORTB=5;
if (bit_is_set(PIND, 2)) PORTB=6;
if (bit_is_set(PIND, 1)) PORTB=7;
if (bit_is_set(PIND, 0)) PORTB=8;
//third column
PORTD =0b11011111;
if (bit_is_set(PIND, 3)) PORTB=9;
if (bit_is_set(PIND, 2)) PORTB=10;
if (bit_is_set(PIND, 1)) PORTB=11;
if (bit_is_set(PIND, 0)) PORTB=12;
//fourth column
PORTD =0b11101111;
if (bit_is_set(PIND, 3)) PORTB=13;
if (bit_is_set(PIND, 2)) PORTB=14;
if (bit_is_set(PIND, 1)) PORTB=15;
if (bit_is_set(PIND, 0)) PORTB=16;
}
}
Now I know I'm missing your question because this code has nothing in it that uses Dean's LCD code. I thought your question was about getting the output of a keypad to show on a the Butterfly LCD using Dean's code, but I don't see anywhere that you use Dean's code, so what am I missing?
sorry..
i really confuse now..
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
am i using a wrong coding for this keypad?
what the function of #include "LCD_Driver.h"
if my keypad program is wrong, can you help and guide me how to make my project works or can you give some suggestion what link should i go and guidelines to settle this problem
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
Just #include'ing a .h file does NOT make use of any of the facilities it provides. This only happens when you call one or more of the functions that it documents.
To USE the LCD library you should be calling LCD_Init() near the start of your program and then later (probably) LCD_puts() to put message strings on the display. Otherwise what were you expecting to see on the display?
Posted by smileymicros: Mon. Apr 6, 2009 - 05:09 PM
1
2
3
4
5
Total votes: 0
amiraliff wrote:
sorry..
i really confuse now..
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
am i using a wrong coding for this keypad?
what the function of #include "LCD_Driver.h"
if my keypad program is wrong, can you help and guide me how to make my project works or can you give some suggestion what link should i go and guidelines to settle this problem
thanks :?
Please read: https://www.avrfreaks.net/index.p...
Then get the Butterfly Quick Start Guide from my website along with the Butterfly FAQ and a few other free and helpful documents that you can use to get started. I would further suggest you look at some of the source code I provide and at the Smiley's Workshops to learn the fundamentals before attempting a keypad.
After reading all this then if you have additional questions please start a new thread on using a keypad with a Butterfly. This tread is not the appropriate place for this discussion.
Posted by JohanEkdahl: Sat. Apr 25, 2009 - 10:51 PM
1
2
3
4
5
Total votes: 0
Quote:
so where should i put the main() function
In one of your C source files.
In the earlier posts in this thread you reported that you succeeded to build and download a complete AVR application. This implies that you have at least some knowledge about the main function, why it is needed and where it should go, yes? If not, now is a good time to get a good book on the C programming language and start reading.
You do realise that Deans code in LCD_driver.c and LCD_driver.h is the LCD driver only with no main program? (In the Tutorial thread where he presented the driver he has posted a small main program a few posts down).
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
In no power conditions nothing should appear - the crystals in the LCD need an AC biasing voltage continually applied to keep them twisted so they block the polarised light. If you remove power that process stops (except in "bistable") and they all untwist so that the display appears blank. If you are seeing something other than this then there MUST be power still applied or you have ghosts in the machine!
Posted by JohanEkdahl: Mon. May 4, 2009 - 04:25 PM
1
2
3
4
5
Total votes: 0
Quote:
i'm trying to use keypad and want to display it on my butterfly lcd
can i use dean's lcd driver?
Maybe, but you have to prove it to us...
Point is: Given the vague technical description the answer probably is "yes, Deans driver should be usable in such a case".
Give us a stronger technical description and the answer will be more definite.
Or, do what I suspect you wanted to all along and ask "How?". In that case you must supply us with a more definite description of your project at this stage, or you will get no meaningful answers at all.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
LCD_puts() is looking for a string as it's argument (ie, an array of characters with a null at the end).
To print the value of a variable, you need to convert it to a string first. You can use sprintf, itoa, or convert it yourself.
/mike
Posted by JohanEkdahl: Wed. May 6, 2009 - 06:04 AM
1
2
3
4
5
Total votes: 0
Quote:
is there another possibility to convert it to a string by myself?
1. Look for a function itoa(...) in your run-time library.
2. Yes, you could write it yourself. Repeated integer division and remainder by 10 should give you the digits (from least to most significant) in the remainder and the number for the next repetition in the division result. In order to convert a single digit integer value to the corresponding character representation yuo just add the integer representation of the digit '0', like so
digitAsCharacter = digitInAnInteger + '0';
You build up your string from right to left (that order is the tricky part), and don't forget that the string should have a terminating zero char!
If you do a search of this site you will probably find several discussions on alternative implementations that might be more efficient in some aspect.
Unless you are in a real trouble with flash memory and really know what you are doing, I'd stay with itoa(...).
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
Posted by snelltaylor: Sat. Nov 14, 2009 - 12:51 AM
1
2
3
4
5
Total votes: 0
Just to drag up a really old post . . . quick question on the interrupt routine. You say that the LCD ISR allows other interrupts, but I don't see anything explicitly allowing it. I would expect an sei() or similar, is that the case? In my application, I'm running TC1 at Fclk/8, and need to get a OC1B to do something. It seems like that just isn't happening frequently, and I'm guessing that if that interrupt doesn't get the timer value in the 8 clock cycles where the timer value and OC1B match, the interrupt is lost. I've checked all my other interrupts, and they're a couple clock cycles long at worst. Am I at least looking in the right place?
Thanks!
Posted by abcminiuser: Sat. Nov 14, 2009 - 03:15 AM
1
2
3
4
5
Total votes: 0
Hi,
You are correct that the latest version does not explicitly re-enable interrupts in the ISR to allow other interrupts to interrupt it while the ISR is running (boy, that's a mouthful to say!). The fix is as simple as changing:
ISR(LCD_vect)
To:
ISR(LCD_vect, ISR_NOBLOCK)
In a recent version of avr-libc (i.e. less than a year or two old).
- Dean :twisted:
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
Posted by snelltaylor: Sat. Nov 14, 2009 - 07:20 PM
1
2
3
4
5
Total votes: 0
Cool, thanks for the input. I'll give it a shot. I had tried manually enabling interrupts (sei) and disabling the LCD interrupt at the beginning of the interrupt, and re-enabling it at the end (again, a mouthful that is way to confusing), but no result. I ended up just changing my code around a bit to do a hardware PWM mode rather than software, but on the butterfly, that means PB5 is the only option when using the joystick, and it's tied to the speaker, very annoying results :P Time to start looking at a different controller and an external LCD if I get serious about this project! Thanks again!
I was getting all kinds of errors when I tried to compile code containing Atmel's LCD drivers, so I decided to use this one. I got the sample code Dean wrote to compile with no errors or warnings using WinAVR.
When I download the HEX file to my board using AVR Studio, nothing happens. I'm pretty sure I'm downloading it right, because when I put the default Butterfly program back on there, it works fine.
Posted by nickkennedy: Sat. May 28, 2011 - 08:48 PM
1
2
3
4
5
Total votes: 0
I also had trouble getting the LCD_WriteChar() function to work until I added universalist's macro and took "static inline" off of the original definition. Which I don't understand but guess I don't need to at this point. It took me a couple of tries to see that the order of the arguments was reversed ... not sure if that was intentional.
I appreciate Dean's tutorial. I'm new to using C on MCUs although I've been playing with them in assembler for quite some time. Lots to learn! I'm pursing two paths: first, starting with tiny programs that, for example, beep the piezo sounder when the joystick is moved, and second, trying to use other people's code (such as this driver) -- which I suppose is one of the big advantages of C.
Maybe he fails to realize that this is page 3 of the thread...
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
Tophehehe..
sorry guys...
- Log in or register to post comments
Tophey there..
the code that dean post on the first page of this forum really help me
but my question is which code i want to use.is it .c or .h.
when i build the .c code using avr studio it stated that this code have error but when i build with .h code there is no error
could someone tell me which code are suitable for this software?(avr studio)
- Log in or register to post comments
TopYou need both .c and .h files. The question reveals that your knowledge of the C programming language is close to none. You should get a good book on C and start reading.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
Topi still can't build the code
there are errors and warning
these are the error that my avr show when i build that code
hope you can help me
- Log in or register to post comments
TopAs often the case the only important error in all thta is:
I'd concentrate on that one first and once you've resolved it I'm guessing the other errors will evaporate.
- Log in or register to post comments
Topoh ok..
so i must install the LCD driver 1st rite??
- Log in or register to post comments
Top"install" - what are you talking about?
You go to the first post in this thread. You select all the text under LCD_Driver.c you copy it, you create a blank file called LCD_Driver.c and paste it in then save it. You then do the same with the text under LCD_Driver.h and save that to LCD_Driver.h. You make sure these two files are in the same directory as your other project files. In one of your own .c files where you plan to use functions in LCD_Driver.c you simply add the line:
Then in the list of files to be built in the project you add LCD-Driver.c to the list. Now build the project and it should all just work.
Cliff
- Log in or register to post comments
TopMake sure that a copy of both the .c and the .h file are in the directory used by your AVRStudio project. In the AVR GCC directory tree on the left of AVRStudio click on 'Source Files' and 'Add Existing File(s)' to add the .c file, then in the 'Header Files' also use 'Add Existing File(s)' to add the .h file. Now when you click Compile AVRStudio should be able to find both files.
Smiley
- Log in or register to post comments
Topi follow what you ask me to do and i can build it.
but the prob is the program shows warning there
what the problem with that warning
- Log in or register to post comments
TopWell what do you THINK that warning means?
- Log in or register to post comments
TopThe problem is exactly what the warning says. There is no newline at the end of the file. How can that be unclear?
IIRC this can be a problem for the some compilers (not seeing the last token in the file). The simple remedy is to edit those files. Go to the last line. Place the caret after that last character on the line. Hit enter. Save the file and exit. Repeat for all files that generate the warning.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
Topi follow what you ask me to do and i can build it.
but the prob is the program shows warning there
what the problem with that warning
- Log in or register to post comments
TopI'm out.
- Log in or register to post comments
Topsorry about the double post..
internet connection at my place so slow so it cause error like that
anyway thanks for the advice
my program now work properly without warning
you are really nice people
- Log in or register to post comments
TopHye,
I have compile both keypad and lcd butterfly code C in a AVR Studio without warning and error.
But after i downloaded to AVR there was a buzzing sound appear.
Why is it happened?? Is it my coding mistake or AVR problem?
I attach the code for reference. Hope someone can help.. :cry:
Attachment(s):
- Log in or register to post comments
TopLook at the Butterfly schematic to see which pin is attached to the piezo element (buzzer) then note which part of you code is toggling that pin at an audio frequency.
Smiley
- Log in or register to post comments
Topi already change my keypad from PORTB to PORTD and i don't hear any "buzzing" sound.
but my problem now is the LCD doesn't show anything when i download the program to AVR
i'm using LCD driver which i get on the 1st thread of this forum
could anybody help me
- Log in or register to post comments
TopYou really need to look at the Butterfly schematic.
Also read:
http://www.smileymicros.com/down...
Smiley
- Log in or register to post comments
Topi already look the butterfly schematic but i still got the problem..
my keypad cannot sent data to buttefly lcd
this is my keypad code
what's the problem of this code because i can compile it on avr studio
is there any additional connection to interface this keypad and this butterfly lcd??
i really appreciate your kindest to help me find this problem
- Log in or register to post comments
TopI must be misunderstanding your question since both the Butterfly schematics and the 'Butterfly Alternate Pin Uses' document that I provided a link to for you both show that PORTD is connected to the PORTD pad AND to 8 of the LCD pins - so as one should see on the schematic or read in the document, you cannot use PORTD for both the LCD and as an input port at the same time.
And I just looked at your code and now my question is: what function in your code is sending data to the LCD? Earlier you said you changed your keypad from PORTB to PORTD and the buzzing stopped, but your code doesn't show this. Were you trying to turn on individual LCD elements with the write to PORTD?
And looking further back, I see that Dean suggested you use his LCD driver, so now I'm even more confused about what you are asking.
Please answer:
1. Did you try to use Dean's driver?
2. If so, why doe's it not show up in you code listing?
3. If you read the Butterfly Schematics how could you not know that your code would cause the Piezo element to buzz?
4. You said that after you changed ports the buzzing stopped, but you show the same code unchanged?
4. And if you read the Schematics and the Alternate Pin Use document, how could you not know that moving the keypad to PORTD would interfere with the LCD?
Again, I must be missing something in your question.
Smiley
- Log in or register to post comments
Topoh sorry..
i didn't mention it to you before..
after read the schematic i know that the Piezo element is in PINB5.
It's true that in the early i try to connect my keypad to PORTD but after reading the schematic, i change it back to PORTB because i realize PORTD will interfere the LCD.
my answer for your question..
1. yes, i 'm using dean's driver.
2. i send you the full code of my program include Dean's driver.
3. i already ask my friends.they said maybe the connection from the keypad to butterfly makes the buzzing sound.
your question 4 and 5 i already explain at above
sorry again because sending you the not update program
here i send you my new program
hope i already answer your question..
thanks
Attachment(s):
- Log in or register to post comments
TopYour keypad.c code:
Now I know I'm missing your question because this code has nothing in it that uses Dean's LCD code. I thought your question was about getting the output of a keypad to show on a the Butterfly LCD using Dean's code, but I don't see anywhere that you use Dean's code, so what am I missing?
Smiley
- Log in or register to post comments
Topsorry..
i really confuse now..
what do you mean by this keypad code has nothing in it that uses Dean's LCD code.
am i using a wrong coding for this keypad?
what the function of #include "LCD_Driver.h"
if my keypad program is wrong, can you help and guide me how to make my project works or can you give some suggestion what link should i go and guidelines to settle this problem
thanks :?
- Log in or register to post comments
TopJust #include'ing a .h file does NOT make use of any of the facilities it provides. This only happens when you call one or more of the functions that it documents.
To USE the LCD library you should be calling LCD_Init() near the start of your program and then later (probably) LCD_puts() to put message strings on the display. Otherwise what were you expecting to see on the display?
Cliff
- Log in or register to post comments
TopPlease read:
https://www.avrfreaks.net/index.p...
Then get the Butterfly Quick Start Guide from my website along with the Butterfly FAQ and a few other free and helpful documents that you can use to get started. I would further suggest you look at some of the source code I provide and at the Smiley's Workshops to learn the fundamentals before attempting a keypad.
After reading all this then if you have additional questions please start a new thread on using a keypad with a Butterfly. This tread is not the appropriate place for this discussion.
Smiley
- Log in or register to post comments
Tophi again
im having a problem with dean's lcd driver
when i try to compile this driver, there is an error's appear
hope u guys out there can help me
- Log in or register to post comments
TopWell that's telling you that no where in the files being compiled is there a function called main() - all C programs must have this.
- Log in or register to post comments
Topoh...
so where should i put the main() function
i try to write it but there still have an error
so can u tell me where the best place i should write this function
- Log in or register to post comments
Tophi
i already download dean's driver on my butterfly but it shows nothing on my butterfly lcd.
what's the problem?
and what's the function of this code (i take from dean's driver)
hope anyone can explain it to me
- Log in or register to post comments
TopThat's just data saying which segments should be lit to display the character listed in each comment
- Log in or register to post comments
Tophi
i already download dean's driver on my butterfly but it shows nothing on my butterfly lcd.
what's the problem?
anyone can help??
- Log in or register to post comments
TopIn one of your C source files.
In the earlier posts in this thread you reported that you succeeded to build and download a complete AVR application. This implies that you have at least some knowledge about the main function, why it is needed and where it should go, yes? If not, now is a good time to get a good book on the C programming language and start reading.
You do realise that Deans code in LCD_driver.c and LCD_driver.h is the LCD driver only with no main program? (In the Tutorial thread where he presented the driver he has posted a small main program a few posts down).
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
TopHey Guys,
I´m bit confused about the test program from Dean he wrote:
LCD_puts_f(PSTR("AVR BUTTERFLY GCC"));
LCD_puts("AVR BUTTERFLY GCC");
So in according to the LCD_Driver.c:
LCD_puts_f is storing data in the flash and LCD_puts in the SRAM (so its volatile).
If I write something only wit LCD_puts_f on the LCD screen it will disappear after the power was shutted of, but it´s not the case.
So the questition is why the data is still there?
Thanks
- Log in or register to post comments
TopWell two options:
1) you've actually found a bistable (aka "Zero power") LCD - http://en.wikipedia.org/wiki/Liq... or
2) there's still power (maybe just a trickle capacitance?) to the LCD
- Log in or register to post comments
TopOk, but normally under no-power conditions after switching of the data from SRAM should be erased, isn´t it so?
- Log in or register to post comments
TopIn no power conditions nothing should appear - the crystals in the LCD need an AC biasing voltage continually applied to keep them twisted so they block the polarised light. If you remove power that process stops (except in "bistable") and they all untwist so that the display appears blank. If you are seeing something other than this then there MUST be power still applied or you have ghosts in the machine!
- Log in or register to post comments
Tophi
i'm trying to use keypad and want to display it on my butterfly lcd
can i use dean's lcd driver?
- Log in or register to post comments
TopMaybe, but you have to prove it to us...
Point is: Given the vague technical description the answer probably is "yes, Deans driver should be usable in such a case".
Give us a stronger technical description and the answer will be more definite.
Or, do what I suspect you wanted to all along and ask "How?". In that case you must supply us with a more definite description of your project at this stage, or you will get no meaningful answers at all.
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
TopHey,
I´ve tried to display a variable over the LCD_puts function, but it didn´t work.
So I wrote simple into the main function:
int x = 1;
LCD_puts(x);
But it comes nothing. It works, however, if I write insted: LCD_puts("x");
Where is the problem?
Thanks!
- Log in or register to post comments
TopLCD_puts() is looking for a string as it's argument (ie, an array of characters with a null at the end).
To print the value of a variable, you need to convert it to a string first. You can use sprintf, itoa, or convert it yourself.
/mike
- Log in or register to post comments
TopThanks for the fast anwser! Now I got it, it was just too long that I programmed the last time.
But I noticed, that sprintf needs a lot of memory, is there another possibility to convert it to a string by myself?
- Log in or register to post comments
Top1. Look for a function itoa(...) in your run-time library.
2. Yes, you could write it yourself. Repeated integer division and remainder by 10 should give you the digits (from least to most significant) in the remainder and the number for the next repetition in the division result. In order to convert a single digit integer value to the corresponding character representation yuo just add the integer representation of the digit '0', like so
You build up your string from right to left (that order is the tricky part), and don't forget that the string should have a terminating zero char!
If you do a search of this site you will probably find several discussions on alternative implementations that might be more efficient in some aspect.
Unless you are in a real trouble with flash memory and really know what you are doing, I'd stay with itoa(...).
As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here.
No guarantees, but if we don't report problems they won't get much of a chance to be fixed! Details/discussions at link given just above.
"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]
- Log in or register to post comments
Top@JohanEkdahl: Thanks and greetings from Lulea!
- Log in or register to post comments
TopJust to drag up a really old post . . . quick question on the interrupt routine. You say that the LCD ISR allows other interrupts, but I don't see anything explicitly allowing it. I would expect an sei() or similar, is that the case? In my application, I'm running TC1 at Fclk/8, and need to get a OC1B to do something. It seems like that just isn't happening frequently, and I'm guessing that if that interrupt doesn't get the timer value in the 8 clock cycles where the timer value and OC1B match, the interrupt is lost. I've checked all my other interrupts, and they're a couple clock cycles long at worst. Am I at least looking in the right place?
Thanks!
- Log in or register to post comments
TopHi,
You are correct that the latest version does not explicitly re-enable interrupts in the ISR to allow other interrupts to interrupt it while the ISR is running (boy, that's a mouthful to say!). The fix is as simple as changing:
To:
In a recent version of avr-libc (i.e. less than a year or two old).
- Dean :twisted:
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
- Log in or register to post comments
TopCool, thanks for the input. I'll give it a shot. I had tried manually enabling interrupts (sei) and disabling the LCD interrupt at the beginning of the interrupt, and re-enabling it at the end (again, a mouthful that is way to confusing), but no result. I ended up just changing my code around a bit to do a hardware PWM mode rather than software, but on the butterfly, that means PB5 is the only option when using the joystick, and it's tied to the speaker, very annoying results :P Time to start looking at a different controller and an external LCD if I get serious about this project! Thanks again!
- Log in or register to post comments
TopI was getting all kinds of errors when I tried to compile code containing Atmel's LCD drivers, so I decided to use this one. I got the sample code Dean wrote to compile with no errors or warnings using WinAVR.
When I download the HEX file to my board using AVR Studio, nothing happens. I'm pretty sure I'm downloading it right, because when I put the default Butterfly program back on there, it works fine.
Any suggestions?
- Log in or register to post comments
TopI added sei() and the program worked!!! I've been working on this for 2 weeks!!! I'm so happy!! Here's the code I used:
#include
#include
int main(void)
{
sei();
LCD_Init();
LCD_puts_f(PSTR("AVR BUTTERFLY GCC"));
LCD_puts("AVR BUTTERFLY GCC");
for (;;) {}
return 0;
}
- Log in or register to post comments
TopI also had trouble getting the LCD_WriteChar() function to work until I added universalist's macro and took "static inline" off of the original definition. Which I don't understand but guess I don't need to at this point. It took me a couple of tries to see that the order of the arguments was reversed ... not sure if that was intentional.
I appreciate Dean's tutorial. I'm new to using C on MCUs although I've been playing with them in assembler for quite some time. Lots to learn! I'm pursing two paths: first, starting with tiny programs that, for example, beep the piezo sounder when the joystick is moved, and second, trying to use other people's code (such as this driver) -- which I suppose is one of the big advantages of C.
Nick
- Log in or register to post comments
TopPages