• AVR Freaks

Hot!Error: expression syntax

Author
Jeet27
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2018/08/14 10:40:41
  • Location: 0
  • Status: offline
2018/10/23 13:14:34 (permalink)
0

Error: expression syntax

I am trying to show a few horizontal lines on an OLED display. But I'm getting a syntax error. Please can someone correct my code for the same? Thank You in advance.
 
The following is my code:
 
//*************** SOURCE FILE ********************
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "Alphabet.h"
#include <string.h>
#define ADDR_MODE 2

#define SSD1306B_VCOMH_DESELECT_0p65xVCC_00 (0x00)
#define SSD1306B_COM_CONFIG_SEQUENTIAL_LEFT_02 (0x02)
#define SSD1306B_VCOMH_DESELECT_0p71xVCC_10 (0x10)
#define SSD1306B_COM_CONFIG_ALTERNATE_LEFT_12 (0x12)
#define SSD1306B_DCDC_CONFIG_7p5v_14 (0x14)
#define SSD1306B_DCDC_CONFIG_6p0v_15 (0x15)
#define SSD1306B_VCOMH_DESELECT_0p77xVCC_20 (0x20)
#define SSD1306B_COM_CONFIG_SEQUENTIAL_RIGHT_22 (0x22)
#define SSD1306B_DEACTIVATE_SCROLL_2E (0x2E) //Missing from Datasheet
#define SSD1306B_VCOMH_DESELECT_0p83xVCC_30 (0x30)
#define SSD1306B_COM_CONFIG_ALTERNATE_RIGHT_32 (0x32)
#define SSD1306B_DISPLAY_START_LINE_40 (0x40)
#define SSD1306B_CONTRAST_PREFIX_81 (0x81)
#define SSD1306B_DCDC_CONFIG_PREFIX_8D (0x8D)
#define SSD1306B_DCDC_CONFIG_8p5v_94 (0x94)
#define SSD1306B_DCDC_CONFIG_9p0v_95 (0x95)
#define SSD1306B_SEG0_IS_COL_0_A0 (0xA0)
#define SSD1306B_SEG0_IS_COL_127_A1 (0xA1)
#define SSD1306B_ENTIRE_DISPLAY_NORMAL_A4 (0xA4)
#define SSD1306B_ENTIRE_DISPLAY_FORCE_ON_A5 (0xA5)
#define SSD1306B_INVERSION_NORMAL_A6 (0xA6)
#define SSD1306B_INVERSION_INVERTED_A7 (0xA7)
#define SSD1306B_MULTIPLEX_RATIO_PREFIX_A8 (0xA8)
#define SSD1306B_SET_MASTER_CONFIGURATION_AD (0xAD) //Missing from Datasheet
#define SSD1306B_DISPLAY_OFF_YES_SLEEP_AE (0xAE)
#define SSD1306B_DISPLAY_ON_NO_SLEEP_AF (0xAF)
#define SSD1306B_SCAN_DIR_UP_C0 (0xC0)
#define SSD1306B_SCAN_DIR_DOWN_C8 (0xC8)
#define SSD1306B_DISPLAY_OFFSET_PREFIX_D3 (0xD3)
#define SSD1306B_CLOCK_DIVIDE_PREFIX_D5 (0xD5)
#define SSD1306B_COLOR_AND_LOW_POWER_DISPLAY_MODE_D8 (0xD8) //Missing from Datasheet
#define SSD1306B_PRECHARGE_PERIOD_PREFIX_D9 (0xD9)
#define SSD1306B_COM_CONFIG_PREFIX_DA (0xDA)
#define SSD1306B_VCOMH_DESELECT_PREFIX_DB (0xDB)

void sendcommand(uint8_t command)
{
RB3 = 0;//CLR_RS;
RB0 = 0;//CLR_CS;
RB2 = 0;//CLR_RW;
LATD = command;
RB2 = 1;//SET_RW;
RB0 = 1;//SET_CS;
}
//============================================================================
void senddata(uint8_t data)
{
RB3 = 1;//SET_RS;
RB0 = 0;//CLR_CS;
RB2 = 0;//CLR_RW;
LATD = data;
RB2 = 1;//SET_RW;
RB0 = 1;//SET_CS;
}
//============================================================================
void setAddr(unsigned char page,unsigned char lCol,unsigned char hCol)
{
sendcommand(page);//Set Page Start Address
sendcommand(lCol);//Set Lower Column Start Address
sendcommand(hCol);//Set Higher Column Start Address
}
//============================================================================
void Home_Addr(void)
{
#if (ADDR_MODE<2)
sendcommand(0x22);//Set Page Address
setPageAddr(0,7);
sendcommand(0x21);//Set Column Address
setColAddr(0,127);
#else
setAddr(0xb0,0,0x10);
#endif
}
//============================================================================
void fillScreen(uint8_t verticalByte)
{
for(uint8_t line=0;line<8;line++)
{
sendcommand(0x00); //lower column address
sendcommand(0x10); //upper column address
sendcommand(0xB0+line); //set page address
// Now that we are aligned at the left of the page
for(uint8_t x = 0; x <= 127; x++ )
{
senddata(verticalByte);
}
}
}
//============================================================================
void horizontal_line(uint8_t x1, uint8_t y, uint8_t x2)
{
register unsigned int8_t *LCD_Memory;
register unsigned int8_t column;
register unsigned int8_t Set_Mask;

//Bail for bogus parametrers.
if((x2<x1)||
(127<x1)||
(127<x2)||
(63<y))
return;

//Calculate the address of the first unsigned int8 in display in LCD_Memory
LCD_Memory=&fillScreen[y>>3][x1];

//Calculate Set_Mask, the vertical mask that we will or with
//LCD_Memory to clear the space before we or in the data from the
//font. It is 9 pixels.
Set_Mask=0x01<<(y&0x07);

//Move across memory, oring the mask in.
for(column=x1;column<=x2;column++)
{
LCD_Memory[0]|=Set_Mask;
LCD_Memory++;
}
}
//============================================================================
void display_init(void)
{
__delay_ms(1000);
RB1 = 0;//CLR_RESET;
__delay_ms(1000);
RB1 = 1;//SET_RESET;
__delay_ms(1000);
sendcommand(SSD1306B_DISPLAY_OFF_YES_SLEEP_AE);//Set Display ON/OFF =>0xae:Display off
sendcommand(0x20);//Set Memory Addressing Mode
sendcommand(ADDR_MODE);
Home_Addr();

sendcommand(0x81);//Set contrast Control for BANK0
sendcommand(0x80);
sendcommand(0x40);//Set Display Start Line
sendcommand(0xa1);//Set Segment Re-map =>0xa0:column addr. 0 is mapped to SEG0
sendcommand(0xa4);//Entire Display On =>0xa4:resume to RAM content display
sendcommand(0xa6);//Set Normal/Inverse Display =>0xa6:Normal,0xa7:inverse
sendcommand(0xa8);//Set Multiplex Ratio
sendcommand(0x3f);//63
sendcommand(0xad);//Master Configuration
sendcommand(0x8e);
sendcommand(0xc0);//Set COM Output Scan Direction =>0xc0:scan from COM0 to COM63, 0xc8:scan from COM63 to COM0
sendcommand(0xd3);//Set Display Offset
sendcommand(0x00);
sendcommand(0xd5);//Set Display Clock Divide Ratio/Oscillator Frequency
sendcommand(0xf0);
sendcommand(0xd8);//Set Area Color Mode ON/OFF & Low Power Display Mode
sendcommand(0x05);//0x05:monochrome mode and low power display mode
sendcommand(0xd9);//Set Pre-charge Period
sendcommand(0xf1);
sendcommand(0xda);//Set COM Pins Hardware Configuration
sendcommand(0x12);
sendcommand(0xdb);//Set Vcomh Deselect Level
sendcommand(0x40);
sendcommand(0x2e);//deactivate scroll
sendcommand(SSD1306B_DISPLAY_ON_NO_SLEEP_AF);//Set Display ON/OFF =>0xaf:Display on
}
//----------------------------------------------------------------------------
void Demo(void)
{
uint8_t pix;
for (pix=0; pix<=127; pix++)
{
fillScreen(0x00);
__delay_ms(1000);;

int8_t xl=0;
int8_t yl=0;
horizontal_line(xl + 10,
yl + 10,
xl + 120);
horizontal_line(xl + 20,
yl + 30,
xl + 100);
horizontal_line(xl + 9, yl + -13, xl + 121);
}
}
//============================================================================
void setup( void )
{
TRISD = 0;
TRISB = 0;

RB1 = 0;//CLR_RESET;
RB3 = 0;//CLR_RS;
RB0 = 1;//SET_CS;
RB4 = 1;//SET_RD;
RB5 = 1;//SET_DISPLAY;

display_init();
}
//============================================================================
void main (void)
{
setup();
__delay_ms(50);
while(1)
{
Demo();
}
}

 
 
 
//*************** HEADER FILE ********************
#pragma config RETEN = ON // VREG Sleep Enable bit (Enabled)
#pragma config INTOSCSEL = HIGH // LF-INTOSC Low-power Enable bit (LF-INTOSC in High-power mode during Sleep)
#pragma config SOSCSEL = HIGH // SOSC Power Selection and mode Configuration bits (High Power SOSC circuit selected)
#pragma config XINST = OFF // Extended Instruction Set (Enabled) // SET it to OFF because of error

// CONFIG1H
#pragma config FOSC = INTIO2 // Oscillator (Internal RC oscillator)
#pragma config PLLCFG = OFF // PLL x4 Enable bit (Disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor (Disabled)
#pragma config IESO = OFF // Internal External Oscillator Switch Over Mode (Disabled)

// CONFIG2L
#pragma config PWRTEN = OFF // Power Up Timer (Disabled)
#pragma config BOREN = OFF // Brown Out Detect (Disabled in hardware, SBOREN disabled)
#pragma config BORV = 2 // Brown-out Reset Voltage bits (2.0V)
#pragma config BORPWR = ZPBORMV // BORMV Power level (ZPBORMV instead of BORMV is selected)

// CONFIG2H
#pragma config WDTEN = OFF // Watchdog Timer (WDT disabled in hardware; SWDTEN bit disabled)
#pragma config WDTPS = 32768 // Watchdog Postscaler (1:32768)

// CONFIG3L
#pragma config RTCOSC = SOSCREF // RTCC Clock Select (RTCC uses SOSC)
#pragma config EASHFT = ON // External Address Shift bit (Address Shifting enabled)
#pragma config ABW = MM // Address Bus Width Select bits (8-bit address bus)
#pragma config BW = 16 // Data Bus Width (16-bit external bus mode)
#pragma config WAIT = OFF // External Bus Wait (Disabled)

// CONFIG3H
#pragma config CCP2MX = PORTC // CCP2 Mux (RC1)
#pragma config ECCPMX = PORTE // ECCP Mux (Enhanced CCP1/3 [P1B/P1C/P3B/P3C] muxed with RE6/RE5/RE4/RE3)
#pragma config MSSPMSK = MSK7 // MSSP address masking (7 Bit address masking mode)
#pragma config MCLRE = ON // Master Clear Enable (MCLR Enabled, RG5 Disabled)

// CONFIG4L
#pragma config STVREN = ON // Stack Overflow Reset (Enabled)
#pragma config BBSIZ = BB2K // Boot Block Size (2K word Boot Block size)

// CONFIG5L
#pragma config CP0 = OFF // Code Protect 00800-03FFF (Disabled)
#pragma config CP1 = OFF // Code Protect 04000-07FFF (Disabled)
#pragma config CP2 = OFF // Code Protect 08000-0BFFF (Disabled)
#pragma config CP3 = OFF // Code Protect 0C000-0FFFF (Disabled)
#pragma config CP4 = OFF // Code Protect 10000-13FFF (Disabled)
#pragma config CP5 = OFF // Code Protect 14000-17FFF (Disabled)
#pragma config CP6 = OFF // Code Protect 18000-1BFFF (Disabled)
#pragma config CP7 = OFF // Code Protect 1C000-1FFFF (Disabled)

// CONFIG5H
#pragma config CPB = OFF // Code Protect Boot (Disabled)
#pragma config CPD = OFF // Data EE Read Protect (Disabled)

// CONFIG6L
#pragma config WRT0 = OFF // Table Write Protect 00800-03FFF (Disabled)
#pragma config WRT1 = OFF // Table Write Protect 04000-07FFF (Disabled)
#pragma config WRT2 = OFF // Table Write Protect 08000-0BFFF (Disabled)
#pragma config WRT3 = OFF // Table Write Protect 0C000-0FFFF (Disabled)
#pragma config WRT4 = OFF // Table Write Protect 10000-13FFF (Disabled)
#pragma config WRT5 = OFF // Table Write Protect 14000-17FFF (Disabled)
#pragma config WRT6 = OFF // Table Write Protect 18000-1BFFF (Disabled)
#pragma config WRT7 = OFF // Table Write Protect 1C000-1FFFF (Disabled)

// CONFIG6H
#pragma config WRTC = OFF // Config. Write Protect (Disabled)
#pragma config WRTB = OFF // Table Write Protect Boot (Disabled)
#pragma config WRTD = OFF // Data EE Write Protect (Disabled)

// CONFIG7L
#pragma config EBRT0 = OFF // Table Read Protect 00800-03FFF (Disabled)
#pragma config EBRT1 = OFF // Table Read Protect 04000-07FFF (Disabled)
#pragma config EBRT2 = OFF // Table Read Protect 08000-0BFFF (Disabled)
#pragma config EBRT3 = OFF // Table Read Protect 0C000-0FFFF (Disabled)
#pragma config EBRT4 = OFF // Table Read Protect 10000-13FFF (Disabled)
#pragma config EBRT5 = OFF // Table Read Protect 14000-17FFF (Disabled)
#pragma config EBRT6 = OFF // Table Read Protect 18000-1BFFF (Disabled)
#pragma config EBRT7 = OFF // Table Read Protect 1C000-1FFFF (Disabled)

// CONFIG7H
#pragma config EBRTB = OFF // Table Read Protect Boot (Disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>


#define _XTAL_FREQ 8000000

 
 
 
 
 
 
 
//******************* Build Comments **************
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/Surefire/Google Drive/UserFolders/Desktop/New_folder/BMS-150_Scarp_code/MPLAB/PIC18F87K22/OLED_8080/Proj1.X'
make -f nbproject/Makefile-default.mk dist/default/production/Proj1.X.production.hex
make[2]: Entering directory 'C:/Users/Surefire/Google Drive/UserFolders/Desktop/New_folder/BMS-150_Scarp_code/MPLAB/PIC18F87K22/OLED_8080/Proj1.X'
"C:\Program Files (x86)\Microchip\xc8\v1.45\bin\xc8.exe" --pass1 --chip=18F87K22 -Q -G --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/Alphabet.p1 Alphabet.c
Alphabet.c:108: warning: (373) implicit signed to unsigned conversion
Alphabet.c:131: error: (195) expression syntax
Alphabet.c:136: warning: (373) implicit signed to unsigned conversion
make[2]: *** [build/default/production/Alphabet.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
Alphabet.c:201: warning: (373) implicit signed to unsigned conversion
Alphabet.c:202: warning: (373) implicit signed to unsigned conversion
Alphabet.c:203: warning: (373) implicit signed to unsigned conversion
Alphabet.c:204: warning: (373) implicit signed to unsigned conversion
Alphabet.c:205: warning: (373) implicit signed to unsigned conversion
Alphabet.c:206: warning: (373) implicit signed to unsigned conversion
Alphabet.c:207: warning: (373) implicit signed to unsigned conversion
Alphabet.c:207: warning: (373) implicit signed to unsigned conversion
Alphabet.c:207: warning: (373) implicit signed to unsigned conversion
(908) exit status = 1
nbproject/Makefile-default.mk:100: recipe for target 'build/default/production/Alphabet.p1' failed
make[2]: Leaving directory 'C:/Users/Surefire/Google Drive/UserFolders/Desktop/New_folder/BMS-150_Scarp_code/MPLAB/PIC18F87K22/OLED_8080/Proj1.X'
nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/Surefire/Google Drive/UserFolders/Desktop/New_folder/BMS-150_Scarp_code/MPLAB/PIC18F87K22/OLED_8080/Proj1.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 304ms)
#1

3 Replies Related Threads

    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11329
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Error: expression syntax 2018/10/23 13:23:23 (permalink)
    +1 (1)
    LCD_Memory=&fillScreen[y>>3][x1];

     
    fillScreen is a function return void and you're using it like it's an array.
     
    You also have lots of potential for read-modify-write issues in that code.
    #2
    Jeet27
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2018/08/14 10:40:41
    • Location: 0
    • Status: offline
    Re: Error: expression syntax 2018/10/23 13:46:04 (permalink)
    0
    Thank You jtemples, for the quick response.
     
    I am able to light all pixels by simply removing the 'Horizontal_line' function and adding the statement "fillScreen(0xFF);" in the main function. It works fine. But I can't display specific lines.
     
    Is there a simple way to overcome this error? or can you give a small example function that could solve this error?
    #3
    mmujumdar
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/04/23 16:27:06
    • Location: 0
    • Status: offline
    Re: Error: expression syntax 2018/10/29 13:37:20 (permalink)
    0
    In this line:
    LCD_Memory=&fillScreen[y>>3][x1];

    the fillScreen function needs appropriate function parameter, this function is currently being used as an array. The correct usage of this function would be something like this:
    fillScreen(byte);
    similar to how it is being used in this line: 
    fillScreen(0x00);
    in the Demo() function. If 2 function parameters are required (since 2 variables 'y' and 'x' are being used), the function declaration and definition can be changed to:
    void fillScreen(uint8_t byte1, uint8_t byte2);

    post edited by mmujumdar - 2018/10/29 13:41:24
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5