10 years, 1 month ago.

keep getting compiler error 18 (missing bracket) for no reason!

Just started a new little project, but for some reason the compiler doesn't recognize my closing brackets! If I copy paste other code into my file it works. SOME of my own brackets he recognizes too, but I see no reason for that either... Any experiences with that, or am I making some stupid mistake?

My code so far:

#include "mbed.h"
//#include "LCD_lib.h"


DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

DigitalOut regsel(p5);
DigitalOut r_w(p6);
DigitalOut enable(p7);


#define DB_MASK 0b100001111000000001000011

PortInOut dbport(Port0, DB_MASK);   // THIS GENERATES AN ERROR FOR A MISSING BRACKET AFTER THE D

int write(int data){
    r_w = 0;
    regsel = 0;
    
    enable = 1;
    
    wait_us(1);
    dbport = data;
    wait_us(1);
    
    enable = 1;
    return 0;
}

int check_busy(){
    r_w = 1;
    regsel = 0;
    while(dbport && 0h80 == true); // HERE AFTER THE 0h
    return 0;
}

int main() {
    wait_ms(50);
   
    while(1) {
        
        write(0b00110000); // HERE AFTER THE 0b //function set
        check_busy();
        write(0b00111000); // HERE AFTER THE 0b //function set
        check_busy();
        write(0b00001111); // HERE AFTER THE 0b //display ON OFF
        check_busy();
        write(0x01);    //Display Clear
        check_busy();
        write(0b00000110);  // HERE AFTER THE 0b
        
    }
}

Question relating to:

Ok, I found my mistake. I did not know that the compiler doesn't like my binary numbers. Switch them nfor hexadecimal representations and everything is fine.

posted by Oskar Hoppe 20 Jul 2015

thanks for updating your question with the solution:) very handy.

posted by Jacob Tsimbilakis 10 Dec 2015
Be the first to answer this question.