Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
abcminiuser
PostPosted: Mar 04, 2006 - 04:08 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

Freaks,

Below is the current code I am using in my ButtLoad project to control the LCD. I rewrote the code from Atmel's Butterfly example for size and speed - the resulting code is nice enough with little bloat. The routines are designed for displaying strings out of flash or SRAM only (no direct character writing, etc). I thought it was worth posting here.

Use LCD_Init(); to initialize the driver (routine stolen from Atmel's code Very Happy). To show a string from SRAM use LCD_puts, or for strings located in flash (see my PROGMEM tutorial) use the LCD_puts_f function. Scrolling is automatic if the string is more than six characters long.

The LCD contrast can be use set between 0x00 (lightest) and 0x0F (darkest) via the LCD_CONTRAST_LEVEL(level) macro.

Use as you see fit.

LCD_Driver.c
Code:
/*
               BUTTLCD -- Butterfly LCD Driver

               Copyright (C) Dean Camera, 2008

            dean [at] fourwalledcubicle [dot] com
                  www.fourwalledcubicle.com
*/

/*
   This is a basic driver for the Butterfly LCD. It offers the ability to
   change the contrast and display strings (scrolling or static) from flash
   or SRAM memory only.
   
   This has been completly rewritten from the Atmel code; in this version, as
   much processing as possible is performed by the string display routines
   rather than the interrupt so that the interrupt executes as fast as possible.
*/

#define INC_FROM_DRIVER
#include "LCD_Driver.h"

//                                  LCD Text            + Nulls for scrolling + Null Termination
static volatile char     TextBuffer[LCD_TEXTBUFFER_SIZE + LCD_DISPLAY_SIZE    + 1] = {};
static volatile uint8_t  StrStart        = 0;
static volatile uint8_t  StrEnd          = 0;
static volatile uint8_t  ScrollCount     = 0;
static volatile uint8_t  UpdateDisplay   = false;
static volatile uint8_t  ShowColons      = false;
       volatile uint8_t  ScrollFlags     = 0;

const           uint16_t LCD_SegTable[] PROGMEM =
{
    0xEAA8,     // '*'
    0x2A80,     // '+'
    0x4000,     // ','
    0x0A00,     // '-'
    0x0A51,     // '.' Degree sign
    0x4008,     // '/'
    0x5559,     // '0'
    0x0118,     // '1'
    0x1e11,     // '2
    0x1b11,     // '3
    0x0b50,     // '4
    0x1b41,     // '5
    0x1f41,     // '6
    0x0111,     // '7
    0x1f51,     // '8
    0x1b51,     // '9'
    0x0000,     // ':' (Not defined)
    0x0000,     // ';' (Not defined)
    0x8008,     // '<'
    0x1A00,     // '='
    0x4020,     // '>'
    0x0000,     // '?' (Not defined)
    0x0000,     // '@' (Not defined)
    0x0f51,     // 'A' (+ 'a')
    0x3991,     // 'B' (+ 'b')
    0x1441,     // 'C' (+ 'c')
    0x3191,     // 'D' (+ 'd')
    0x1e41,     // 'E' (+ 'e')
    0x0e41,     // 'F' (+ 'f')
    0x1d41,     // 'G' (+ 'g')
    0x0f50,     // 'H' (+ 'h')
    0x2080,     // 'I' (+ 'i')
    0x1510,     // 'J' (+ 'j')
    0x8648,     // 'K' (+ 'k')
    0x1440,     // 'L' (+ 'l')
    0x0578,     // 'M' (+ 'm')
    0x8570,     // 'N' (+ 'n')
    0x1551,     // 'O' (+ 'o')
    0x0e51,     // 'P' (+ 'p')
    0x9551,     // 'Q' (+ 'q')
    0x8e51,     // 'R' (+ 'r')
    0x9021,     // 'S' (+ 's')
    0x2081,     // 'T' (+ 't')
    0x1550,     // 'U' (+ 'u')
    0x4448,     // 'V' (+ 'v')
    0xc550,     // 'W' (+ 'w')
    0xc028,     // 'X' (+ 'x')
    0x2028,     // 'Y' (+ 'y')
    0x5009,     // 'Z' (+ 'z')
    0x1441,     // '['
    0x8020,     // '\'
    0x1111,     // ']'
    0x0000,     // '^' (Not defined)
    0x1000      // '_'
};

// ======================================================================================

/*
 NAME:      | LCD_Init
 PURPOSE:   | Initializes the Butterfly's LCD for correct operation, ready to display data
 ARGUMENTS: | None
 RETURNS:   | None
*/
void LCD_Init(void)
{
   // Set the initial contrast level to maximum:
   LCD_CONTRAST_LEVEL(0x0F);

    // Select asynchronous clock source, enable all COM pins and enable all segment pins:
    LCDCRB  = (1<<LCDCS) | (3<<LCDMUX0) | (7<<LCDPM0);

    // Set LCD prescaler to give a framerate of 64Hz:
    LCDFRR  = (0<<LCDPS0) | (3<<LCDCD0);   

   // Enable LCD and set low power waveform, enable start of frame interrupt:
    LCDCRA  = (1<<LCDEN) | (1<<LCDAB) | (1<<LCDIE);
}

/*
 NAME:      | LCD_puts
 PURPOSE:   | Displays a string from flash onto the Butterfly's LCD
 ARGUMENTS: | Pointer to the start of the flash string
 RETURNS:   | None
*/
void LCD_puts_f(const char *FlashData)
{
   /* Rather than create a new buffer here (wasting RAM), the TextBuffer global
      is re-used as a temp buffer. Once the ASCII data is loaded in to TextBuffer,
      LCD_puts is called with it to post-process it into the correct format for the
      LCD interrupt.                                                                */

   strcpy_P((char*)&TextBuffer[0], FlashData);
   LCD_puts((char*)&TextBuffer[0]);
}

/*
 NAME:      | LCD_puts
 PURPOSE:   | Displays a string from SRAM onto the Butterfly's LCD
 ARGUMENTS: | Pointer to the start of the SRAM string
 RETURNS:   | None
*/
void LCD_puts(const char *Data)
{
   uint8_t LoadB       = 0;
   uint8_t CurrByte;

   do
   {
      CurrByte = *(Data++);
      
      switch (CurrByte)
      {
         case 'a'...'z':
            CurrByte &= ~(1 << 5);                   // Translate to upper-case character
         case '*'...'_':                                // Valid character, load it into the array
            TextBuffer[LoadB++] = (CurrByte - '*');
            break;
         case 0x00:                                   // Null termination of the string - ignore for now so the nulls can be appended below
            break;
         default:                                     // Space or invalid character, use 0xFF to display a blank
            TextBuffer[LoadB++] = LCD_SPACE_OR_INVALID_CHAR;
      }
   }
   while (CurrByte && (LoadB < LCD_TEXTBUFFER_SIZE));

   ScrollFlags = ((LoadB > LCD_DISPLAY_SIZE)? LCD_FLAG_SCROLL : 0x00);

   for (uint8_t Nulls = 0; Nulls < 7; Nulls++)
     TextBuffer[LoadB++] = LCD_SPACE_OR_INVALID_CHAR;  // Load in nulls to ensure that when scrolling, the display clears before wrapping
   
   TextBuffer[LoadB] = 0x00;                           // Null-terminate string
   
   StrStart      = 0;
   StrEnd        = LoadB;
   ScrollCount   = LCD_SCROLLCOUNT_DEFAULT + LCD_DELAYCOUNT_DEFAULT;
   UpdateDisplay = true;
}

/*
 NAME:      | LCD_vect (ISR, blocking)
 PURPOSE:   | ISR to handle the display and scrolling of the current display string onto the LCD
 ARGUMENTS: | None
 RETURNS:   | None
*/
ISR(LCD_vect, ISR_NOBLOCK)
{
   if (ScrollFlags & LCD_FLAG_SCROLL)
   {
      if (!(ScrollCount--))
      {
         UpdateDisplay = true;
         ScrollCount   = LCD_SCROLLCOUNT_DEFAULT;
      }
   }

   if (UpdateDisplay)
   {
      for (uint8_t Character = 0; Character < LCD_DISPLAY_SIZE; Character++)
      {
         uint8_t Byte = (StrStart + Character);

         if (Byte >= StrEnd)
           Byte -= StrEnd;
         
         LCD_WriteChar(TextBuffer[Byte], Character);
      }
      
      if ((StrStart + LCD_DISPLAY_SIZE) == StrEnd)    // Done scrolling message on LCD once
        ScrollFlags |= LCD_FLAG_SCROLL_DONE;
      
      if (StrStart++ == StrEnd)
        StrStart     = 1;

       if (ShowColons)
            *((uint8_t*)(LCD_LCDREGS_START + 8)) = 0x01;
        else
            *((uint8_t*)(LCD_LCDREGS_START + 8)) = 0x00;

      UpdateDisplay  = false;                         // Clear LCD management flags, LCD update is complete
   }
}

/*
 NAME:      | LCD_WriteChar (static, inline)
 PURPOSE:   | Routine to write a character to the correct LCD registers for display
 ARGUMENTS: | Character to display, LCD character number to display character on
 RETURNS:   | None
*/
static inline void LCD_WriteChar(const uint8_t Byte, const uint8_t Digit)
{
   uint8_t* BuffPtr = (uint8_t*)(LCD_LCDREGS_START + (Digit >> 1));
   uint16_t SegData = 0x0000;

   if (Byte != LCD_SPACE_OR_INVALID_CHAR)              // Null indicates invalid character or space
     SegData = pgm_read_word(&LCD_SegTable[Byte]);   

   for (uint8_t BNib = 0; BNib < 4; BNib++)
   {
      uint8_t MaskedSegData = (SegData & 0x0000F);

      if (Digit & 0x01)
        *BuffPtr = ((*BuffPtr & 0x0F) | (MaskedSegData << 4));
      else
        *BuffPtr = ((*BuffPtr & 0xF0) | MaskedSegData);

      BuffPtr += 5;
      SegData >>= 4;
   }   
}

/*
 NAME:      | LCD_ShowColons
 PURPOSE:   | Routine to turn on or off the LCD's colons
 ARGUMENTS: | Boolean - true to turn on colons
 RETURNS:   | None
*/
void LCD_ShowColons(const uint8_t ColonsOn)
{
   ShowColons    = ColonsOn;
   UpdateDisplay = true;
}


LCD_Driver.h
Code:
/*
               BUTTLCD -- Butterfly LCD Driver

               Copyright (C) Dean Camera, 2008

            dean [at] fourwalledcubicle [dot] com
                  www.fourwalledcubicle.com
*/

#ifndef LCDDRIVER_H
#define LCDDRIVER_H

   // INCLUDES:
   #include <avr/io.h>
   #include <avr/pgmspace.h>
   #include <avr/interrupt.h>
   #include <stdbool.h>
   
   // EXTERNAL VARIABLES:
   extern volatile uint8_t ScrollFlags;
   
   // DEFINES:
   #define LCD_LCDREGS_START          ((uint8_t*)&LCDDR0)
   #define LCD_SPACE_OR_INVALID_CHAR  0xFF
   
   #define LCD_CONTRAST_LEVEL(level)  do{ LCDCCR = (0x0F & level); }while(0)
   #define LCD_WAIT_FOR_SCROLL_DONE() do{ while (!(ScrollFlags & LCD_FLAG_SCROLL_DONE)) {} }while(0)
   
   #define LCD_SCROLLCOUNT_DEFAULT    6
   #define LCD_DELAYCOUNT_DEFAULT     20
   #define LCD_TEXTBUFFER_SIZE        20
   #define LCD_SEGBUFFER_SIZE         19
   #define LCD_DISPLAY_SIZE           6

   #define LCD_FLAG_SCROLL            (1 << 0)
   #define LCD_FLAG_SCROLL_DONE       (1 << 1)   

   // PROTOTYPES:
   void LCD_puts_f(const char *FlashData);
   void LCD_puts(const char *Data);
   void LCD_Init(void);
   void LCD_ShowColons(const uint8_t ColonsOn);
   
   #if defined(INC_FROM_DRIVER)
     static inline void LCD_WriteChar(const uint8_t Byte, const uint8_t Digit);
   #endif

#endif


- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.


Last edited by abcminiuser on Dec 16, 2009 - 03:27 AM; edited 10 times in total
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
ThanhTran
PostPosted: Nov 29, 2006 - 09:27 AM
Newbie


Joined: Apr 25, 2006
Posts: 18


I downloaded the whole package and gave it a try. I'm loading it to Butterfly using boot loader. With the build from your .zip file, I see a RAM ST displayed on the LCD. But when I built it with my WinAvr environment (no modification), and reloaded it to the Butterfly, I see nothing running (nothing on the screen).

Any idea?

Thanks

ps.
Here is what my WinAvr build looks like:

> "make.exe" all

-------- begin --------
avr-gcc (GCC) 3.3.2
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: Test.c
avr-gcc -c -mmcu=atmega169 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -I"C:\WinAVR\avr\include" -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mcall-prologues -Wall -Wstrict-prototypes -Wendif-labels -Winline -Wa,-adhlns=Test.lst -std=gnu99 -MD -MP -MF .dep/Test.o.d Test.c -o Test.o
cc1.exe: warning: `dwarf-2': unknown or unsupported -g option

Compiling: LCD_Driver.c
avr-gcc -c -mmcu=atmega169 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -I"C:\WinAVR\avr\include" -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mcall-prologues -Wall -Wstrict-prototypes -Wendif-labels -Winline -Wa,-adhlns=LCD_Driver.lst -std=gnu99 -MD -MP -MF .dep/LCD_Driver.o.d LCD_Driver.c -o LCD_Driver.o
cc1.exe: warning: `dwarf-2': unknown or unsupported -g option
LCD_Driver.c:171: warning: return type defaults to `int'
LCD_Driver.c:171: warning: function declaration isn't a prototype
LCD_Driver.c: In function `ISR':
LCD_Driver.c:171: warning: type of `LCD_vect' defaults to `int'
LCD_Driver.c:210: warning: control reaches end of non-void function

Linking: LCDDemo.elf
avr-gcc -mmcu=atmega169 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -I"C:\WinAVR\avr\include" -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mcall-prologues -Wall -Wstrict-prototypes -Wendif-labels -Winline -Wa,-adhlns=Test.o -std=gnu99 -MD -MP -MF .dep/LCDDemo.elf.d Test.o LCD_Driver.o --output LCDDemo.elf -Wl,-Map=LCDDemo.map,--cref -lm

Creating load file for Flash: LCDDemo.hex
avr-objcopy -O ihex -R .eeprom LCDDemo.elf LCDDemo.hex

Creating load file for EEPROM: LCDDemo.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex LCDDemo.elf LCDDemo.eep

Creating Extended Listing: LCDDemo.lss
avr-objdump -h -S LCDDemo.elf > LCDDemo.lss

Creating Symbol Table: LCDDemo.sym
avr-nm -n LCDDemo.elf > LCDDemo.sym

Size after:
LCDDemo.elf :
section size addr
.data 12 8388864
.text 914 0
.bss 53 8388876
.noinit 0 8388929
.eeprom 0 8454144
Total 979



-------- end --------


> Process Exit Code: 0
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Nov 29, 2006 - 10:06 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

You need to update your AVRLibC installation - you've got an older one where "ISR" is not defined. Since it is not defined, WinAVR just treats it as a standard int function, and so it does not handle the ISR interrupt vector.

Download the latest AVRLibC binaries from http://download.savannah.gnu.org/releases/avr/ and extract over the top of the old ones (extract to WinAVR folder, overwrite existing files).

If you really do not wish to update for some reason, then either change "ISR" to "SIGNAL" or use my "Better GCC Interrupt Macro", available in another post in this tutorial forum.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
ThanhTran
PostPosted: Dec 02, 2006 - 06:34 AM
Newbie


Joined: Apr 25, 2006
Posts: 18


Thanks very much for your help Dean. I download the 1.4.5 libc and it works fine now Smile
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Dec 09, 2006 - 08:23 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

I've just updated my first post with my latest code.

I've reduced the code footprint quite a lot, and eliminated the segment buffering (unneeded since the update time is under a few milliseconds). Total ISR time has been reduced, and now the LCD routine can be interrupted by other ISRs. I've coded the interrupt routine in such a way that it cannot interrupt itself, preventing stack overflows.

Eliminating the segment buffering has greatly reduced the RAM requirements of the driver.

Feedback welcome!

EDIT: I've created a simple test file, and linked it against both Atmel and my own driver:

Code:
int main(void)
{
    LCD_Init();
   
   LCD_puts_f(PSTR("AVR BUTTERFLY GCC"));
   LCD_puts("AVR BUTTERFLY GCC");

   for (;;) {}
   
   return 0;
}


My Driver:
Code:
Program:     810 bytes (4.9% Full)
(.text + .data + .bootloader)

Data:         50 bytes (4.9% Full)
(.data + .bss + .noinit)


Atmel's Driver:
Code:
Program:    1106 bytes (6.8% Full)
(.text + .data + .bootloader)

Data:         71 bytes (6.9% Full)
(.data + .bss + .noinit)



Note that the RAM above includes in both cases the 18 byte SRAM string in the test program as well as the RAM used by the drivers.

I'm yet to come up with a good way to measure the speed of the two drivers, so if anyone has any ideas in that respect please put them here.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Henge
PostPosted: Mar 04, 2007 - 01:32 PM
Newbie


Joined: Jan 28, 2007
Posts: 4
Location: Finland

Hello!

I'm newbei and I just uploadted this LCD driver to my Butterfly.
And tried to print the "LCD_puts("RAM STRING");" function,
instead of getting "RAM STRING" I've got "RA*+,W" on my LCD.
Any ideas why this driver doesn't work?
I'v tried few 'homemade' drivers and they doesn't work on my Butterfly,
but they work on my friends old butterfly.
The time that my LCD works is when I put the original software in it.

Any ideas??
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Mar 04, 2007 - 08:52 PM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

That's odd henge - all Butterflies should have identical displays. I've heard of the latest boards having contrast issues, but not incorrect display like you're getting.

1) When did you purchase your Butterfly?
2) Have you made any modifications to the board?
3) What revision of the official firmware did you board use?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Henge
PostPosted: Mar 04, 2007 - 09:25 PM
Newbie


Joined: Jan 28, 2007
Posts: 4
Location: Finland

Jeah, it's odd and even odder is that I accedently fixed it.
I changed the LCD framerate from 32 Hz to 64 Hz:
LCDFRR = (3<<LCDCD0); Now text is right on all segments and now
you can see the text from all the angles. Before you couldn't see the
text directly from front.

I tought that my soldering had damaged the board but when I uploaded the original software (rev07
it worked fine. In the rev07 the frame rate is 32 Hz and it works. I hadn't hat the time to figure this out yet.

If someone has an explantion for this, I'd like to hear it.

-henge Shocked
 
 View user's profile Send private message  
Reply with quote Back to top
triden
PostPosted: Apr 11, 2007 - 03:00 AM
Hangaround


Joined: Mar 27, 2006
Posts: 244
Location: Vancouver, BC

Work on my butterfly, but it won't scroll for some reason. All I see on the screen is "FLASH"..but it won't scroll the whole string. Any ideas why? I compiled with winavr

_________________
-Christan
Summer Student, Chief Tinkerer
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Apr 11, 2007 - 03:28 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

EDIT: Nevermind, I'm tired.

What is the exact string you're trying to scroll? If the string is less than or equal to 6 characters in length it will stay static, and will only scroll if it is larger than the number of connected character cells on the Butterfly's LCD.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
triden
PostPosted: Apr 11, 2007 - 07:46 AM
Hangaround


Joined: Mar 27, 2006
Posts: 244
Location: Vancouver, BC

That's why I am confused. It's set to print the default string in your test.c program which is "FLASH STRING 2". All the screen reads is "FLASH" and if I put in "FLASHSTRING", the screen will read "FLASHS" but won't scroll. Any ideas?


abcminiuser wrote:
EDIT: Nevermind, I'm tired.

What is the exact string you're trying to scroll? If the string is less than or equal to 6 characters in length it will stay static, and will only scroll if it is larger than the number of connected character cells on the Butterfly's LCD.

- Dean Twisted Evil
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Apr 11, 2007 - 08:08 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

Well, if the string is displaying, the ISR is firing correctly - so I assume you've executed a sei(); in your main code. Odd that it isn't scrolling, perhaps I made a copy-paste error somewhere. Can I PM you the updated and known-working driver so you can test it out with your board?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
triden
PostPosted: Apr 12, 2007 - 03:31 AM
Hangaround


Joined: Mar 27, 2006
Posts: 244
Location: Vancouver, BC

You bet, anything helps. I'm a little lost as to why the text won't scroll. I would love to get this driver working.

abcminiuser wrote:
Well, if the string is displaying, the ISR is firing correctly - so I assume you've executed a sei(); in your main code. Odd that it isn't scrolling, perhaps I made a copy-paste error somewhere. Can I PM you the updated and known-working driver so you can test it out with your board?

- Dean Twisted Evil
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Apr 19, 2007 - 08:12 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

I've just updated my original and second posts to new versions of the code. The new code is faster, adds the LCD_WAIT_FOR_SCROLL_DONE() macro - which, as its name implies, causes program execution to halt until the message has scrolled across the LCD - and works with lowercase characters. Obviously the LCD still displays all characters in uppercase, however I've added code to automatically translate the lower case characters into uppercase characters.

New driver size is slightly larger:

Code:
Program:     834 bytes (5.1% Full)
(.text + .data + .bootloader)

Data:         50 bytes (4.9% Full)
(.data + .bss + .noinit)


However should be very slightly faster and fuller-featured. Still beats the Atmel driver by 272 bytes - and should be much faster to boot!

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
ruffy91
PostPosted: Aug 05, 2007 - 02:30 AM
Newbie


Joined: Mar 05, 2007
Posts: 4


Just tried to compile your test file with latest AVR Studio and WinAVR, here the result:

avr-gcc.exe -mmcu=atmega169p -Wall -gdwarf-2 -O0 -MD -MP -MT LCD_Test.o -MF dep/LCD_Test.o.d -c ../LCD_Test.c
In file included from ../LCD_Test.c:3:
../LCD_Driver.c: In function 'LCD_puts':
../LCD_Driver.c:161: error: 'for' loop initial declaration used outside C99 mode
../LCD_Driver.c: In function '__vector_22':
../LCD_Driver.c:191: error: 'for' loop initial declaration used outside C99 mode
../LCD_Driver.c: In function 'LCD_WriteChar':
../LCD_Driver.c:225: error: 'for' loop initial declaration used outside C99 mode
make: *** [LCD_Test.o] Error 1
Build failed with 3 errors and 0 warnings...

Whats my mistake?
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Aug 05, 2007 - 08:35 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

You need to turn on the "C99" C standards mode. By default the compiler compiles in a variation of the old "C89" standard which does not allow for variables to be declared inside of a for loop.

If you're using a makefile, change your -std line to:

Code:
CSTANDARD = -std=gnu99


If using AVRStudio as a frontend:

Project Menu -> Configuration Options. Select the "Custom Options" tab, in the text box type "-std=gnu99" and press the "Add" button. Click "Ok" to close the window and it should work fine.


- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
ruffy91
PostPosted: Aug 05, 2007 - 09:12 AM
Newbie


Joined: Mar 05, 2007
Posts: 4


Thanks
Its a very usefull driver. Very Happy
 
 View user's profile Send private message  
Reply with quote Back to top
wegstar
PostPosted: Sep 06, 2007 - 05:33 AM
Newbie


Joined: Mar 24, 2006
Posts: 15
Location: California

hmm... doesn't seem to work on this Butterfly here.

The LCD shows nothing... and if examined closely, one can see a slight flickering at one end of the LCD, but nothing else.

Could the frequency of the Butterfly specified in the Makefile be the cause of the problem? Confused
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Sep 06, 2007 - 05:42 AM
Moderator


Joined: Jan 23, 2004
Posts: 9826
Location: Trondheim, Norway

The makefile frequency shouldn't make any difference, but by all means give it a go. Did you initialize the driver via the Init routine before writing to it? Are you enabling interrupts?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
wegstar
PostPosted: Sep 06, 2007 - 07:37 AM
Newbie


Joined: Mar 24, 2006
Posts: 15
Location: California

thanks! Laughing
adding a sei(); before the init solved the problem.
From the previous comments I somehow got the notion that I am NOT supposed to enable interrupts for the driver to work... I guess it was pretty much the other way.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits