add AVR Studio pgm_read_byte function to MiKroc (Electronica)

407 views Asked by At

I have a program in AVR Studio V4 with the following code:

#include <avr/pgmspace.h>

void nlcd_Putc(unsigned char c)
{
    unsigned char i;
    if (c>127) c=c-64;  

    for (i = 0; i < 5; i++ )
    {
        nlcd_SendByte(DATA_LCD_MODE,pgm_read_byte(&(nlcd_Font[c-32][i])));
    }

    nlcd_SendByte(DATA_LCD_MODE,0x00); 
}

So when i want to run this code in MiKroC for AVR i get the following error:

128 324 Undeclared identifier 'pgm_read_byte' in expression MyProject.c

Should I add the header avr/pgmspace.h To MiKroc For AVR, or what is the equivalent header to avr/pgmspace.h in Mikroc For AVR?

Thanks a lot.

1

There are 1 answers

0
Soheil Paper On

by addinf this codes to header :

typedef signed char                                             int8;
        typedef unsigned char                                           uint8;
        typedef signed int                                              int16;
        typedef unsigned int                                            uint16;
        typedef signed long int                                         int32;
        typedef unsigned long int                                       uint32; 

        //-----------------------    
        #define PGM_P                                   char flash *
        #define PROGMEM                                 flash
        #define const                                                                       flash
        #define PSTR(x)                                 x

        #define EEMEM                                   eeprom

        #define pgm_read_byte(x)                        (*((uint8  flash *)(x)))
        #define pgm_read_word(x)                        (*((uint16 flash *)(x)))
        #define pgm_read_float(x)                                               (*((uint32 flash *)(x)))
        #define pgm_read_byte_near(x)                                       (*((uint8  flash *)(x)))