This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help with error when compiling LPC1768

hello friends
I'm doing a 8x8 LED matrix with LPC1768 and when I compile I get an error that I can not solve also leave some warnings but I did not care much.
could help me? I leave the whole project in keil

many thanks
Ciernes

Parents
  • So - the difference between you and me is that your editor will show you the line numbers matching your error messages.

    I can't see that from your post.

    None of the error messages seems to be related to any big error earlier in the code but relate to errors on the specific lines the compiler said.

    So why not work through the list and correct them one-by-one.

    Remember that you have 31 bits available in a signed 32-bit integer before you change the sign of the value.
    Like:

            LPC_GPIO1->FIOCLR |= (0x0F << 28);
    


    Index out of range? Isn't that error message giving you a clear indication of what the compiler finds wrong?

    And the error message about const/non-const pointer?

Reply
  • So - the difference between you and me is that your editor will show you the line numbers matching your error messages.

    I can't see that from your post.

    None of the error messages seems to be related to any big error earlier in the code but relate to errors on the specific lines the compiler said.

    So why not work through the list and correct them one-by-one.

    Remember that you have 31 bits available in a signed 32-bit integer before you change the sign of the value.
    Like:

            LPC_GPIO1->FIOCLR |= (0x0F << 28);
    


    Index out of range? Isn't that error message giving you a clear indication of what the compiler finds wrong?

    And the error message about const/non-const pointer?

Children
  • the specific errors are:

    summarizing

    matrix.c(304): error:  #167: argument of type "const uint8_t *" is incompatible with parameter of type "uint8_t *"
    
    #167:           Matrix_NewFrame(ascii[string]);
    
    
    
    
    matrix.c(74): warning:  #61-D: integer operation result is out of range
    
    
    
    #61-d:  LPC_GPIO1->FIODIR |= (0x0F << 28);
    
    
    
    matrix.c(74): warning:  #68-D: integer conversion resulted in a change of sign
    
    
    #68-d:    LPC_GPIO1->FIODIR |= (0x0F << 28);
    
    
    
    matrix.c(108): warning:  #175-D: subscript out of range
    
    
    #175-d:         buffer = matrix[7];
    
    

  • So why do you not then spend some time and think about each error:

    uint8_t matrix[7];
    


    Now many elements does this array have? 7? And their indices? 0, 1, 2, 3, 4, 5, 6.
    So would it then be allowed to use the index 7? Wouldn't that reference the 8th element?

    I already pointed in my previous post to your 0x0F << 28, and mentioned the issues with changing sign. So why not consider using an unsigned number then? Like 0x0Fu or (unsigned)0x0F?

    Your problem with:

    Matrix_NewFrame(ascii[string]);
    

    Matrix_NewFrame() takes an array as a parameter.
    You haven't shown us what ascii is, except that you treat it as if it can be indexed. But is really ascii really a variable of a type that can be indexed like that and the indexed value will represent an array of 8 uint8_t?

    One of the big problems with programming is that you are required to think for every single line of source code you write.

  • I do not understand what ascii is not a variable

    Might you help me fix it

    I do not know how to do well

    other messages and I understand

    thank you

  • So exactly what is ascii then? You are the only one who knows...

    Maybe, just maybe, you should consider a book on the C programming language?

  • right now I'm learning and there are things that even I do not understand.
    I would appreciate very much if you could help me.
    is what is ascii.
    but not how to fix the code

    you have a lot of experience I would like you to help me

    thank you

  • While I do know the meaning of the term ASCII, I have no idea at all about what you main with your ascii[] in your code.

    If it is your code, then you should know.

    If it isn't your code, then that is a danger with getting someone elses code.

    You have just posted where you make use of ascii[], but you haven't shown any declarations.

  • In all likelihood is describes the 8x8 bit map to be painted to the screen for the ASCII character set, @,A,B,C, etc

    uint8_t smiley[] = {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
    
    0x3C 00111100
    0x42 01000010
    0xA5 10100101
    0x81 10000001
    0xA5 10100101
    0x99 10011001
    0x42 01000010
    0x3C 00111100
    
    0x3C   ####
    0x42  #    #
    0xA5 # #  # #
    0x81 #      #
    0xA5 # #  # #
    0x99 #  ##  #
    0x42  #    #
    0x3C   ####
    

  • Yes, that is quite likely.
    In which case it wouldn't have hurt if:

    void Matrix_NewFrame(uint8_t array[8])
    


    was taking a const parameter.

    I'm a little bit surprised why a thread search in my browser didn't let me see these two lines:

    const uint8_t ascii[][8] = 77 I do not write. It is very long
    


    and

    const uint8_t ascii[100][8];
    

  • this is my ascii code
    not what I'm doing wrong
    const uint8_t ascii[128][8] = {{0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0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,0x3C,0x4,0x1C,0x20,0x20,0x1C,0x0}, //5 {0x0,0x18,0x4,0x1C,0x24,0x24,0x18,0x0}, //6 {0x0,0x3C,0x20,0x10,0x10,0x8,0x8,0x0}, //7 {0x0,0x18,0x24,0x18,0x24,0x24,0x18,0x0},//8 {0x0,0x18,0x24,0x24,0x38,0x20,0x1C,0x0},//9 {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, //60 {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0x0,0x18,0x24,0x20,0x10,0x0,0x10,0x0}, //? {0,0,0,0,0,0,0,0}, {0x0,0x18,0x24,0x24,0x3C,0x24,0x24,0x0},//A {0x0,0x1C,0x24,0x3C,0x24,0x24,0x1C,0x0},//B {0x0,0x38,0x4,0x4,0x4,0x4,0x38,0x0}, //C {0x0,0x1C,0x24,0x24,0x24,0x24,0x1C,0x0},//D {0x0,0x3C,0x4,0xC,0xC,0x4,0x3C,0x0}, //E {0x0,0x3C,0x4,0x1C,0x4,0x4,0x4,0x0}, //F {0x0,0x3C,0x4,0x4,0x34,0x24,0x3C,0x0}, //G {0x0,0x24,0x24,0x3C,0x3C,0x24,0x24,0x0},//H {0x0,0x1C,0x8,0x8,0x8,0x8,0x1C,0x0}, //I {0x0,0x3C,0x20,0x20,0x20,0x24,0x18,0x0},//J {0x0,0x24,0x14,0xC,0x14,0x24,0x24,0x0}, //K {0x0,0x4,0x4,0x4,0x4,0x4,0x1C,0x0}, //L {0x0,0x44,0x6C,0x54,0x54,0x54,0x54,0x0},//M {0x0,0x24,0x2C,0x2C,0x34,0x34,0x24,0x0},//N {0x0,0x18,0x24,0x24,0x24,0x24,0x18,0x0},//O {0x0,0x1C,0x24,0x24,0x1C,0x4,0x4,0x0}, //P {0x0,0x18,0x24,0x24,0x24,0x14,0x28,0x0},//Q {0x0,0x1C,0x24,0x24,0x3C,0x14,0x24,0x0},//R {0x0,0x38,0x4,0x18,0x20,0x20,0x1C,0x0}, //S {0x0,0x7C,0x10,0x10,0x10,0x10,0x10,0x0},//T {0x0,0x24,0x24,0x24,0x24,0x24,0x18,0x0},//U {0x0,0x24,0x24,0x24,0x24,0x24,0x18,0x0},//V {0x0,0x44,0x54,0x54,0x54,0x6C,0x44,0x0},//W {0x0,0x44,0x28,0x10,0x10,0x28,0x44,0x0},//X {0x0,0x24,0x24,0x24,0x18,0x10,0x10,0x0},//Y {0x0,0x3C,0x20,0x10,0x8,0x4,0x3C,0x0} ,//Z {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, //100 {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, //110 {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, //120 {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, //127
    };

    /* Array to define the width of a character */
    const uint8_t character_length[128] =
    {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, //SPACE 1, //! 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //A 4, //B 4, //C 4, //D 4, //E 4, //F 4, //G 4, //H 3, //I 4, //J 4, //K 3, //L 5, //M 4, //N 4, //O 4, //P 4, //Q 4, //R 4, //S 5, //T 4, //U 4, //V 5, //W 5, //X 4, //Y 4, //Z 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //100 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //110 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //120 4, 4, 4, 4, 4, 4, 4, //127
    };

  • matrix.h was wrong

    this is the right

    matrix.h

    
    const uint8_t ascii[128][8];
    const uint8_t character_length[128];
    

  • Did you read my comment about "const"?

    Did you complement that comment by taking a closer look about the "const" keyword in any book about the C programming language?

  • Wow this is an uphill struggle...

    {0x0,0x18,0x24,0x2C,0x34,0x24,0x18,0x0},//0
    
    0x00 00000000
    0x18 00011000
    0x24 00100100
    0x2C 00101100
    0x34 00110100
    0x24 00100100
    0x18 00011000
    0x00 00000000
    
    0x00
    0x18    ##
    0x24   #  #
    0x2C   # ##
    0x34   ## #
    0x24   #  #
    0x18    ##
    0x00
    
    {0x0,0x18,0x14,0x10,0x10,0x10,0x3C,0x0},//1
    
    0x00 00000000
    0x18 00011000
    0x14 00010100
    0x10 00010000
    0x10 00010000
    0x10 00010000
    0x3C 00111100
    0x00 00000000
    
    0x00
    0x18    ##
    0x14    # #
    0x10    #
    0x10    #
    0x10    #
    0x3C   ####
    0x00
    

  • Wow this is an uphill struggle...

    {0x0,0x18,0x24,0x2C,0x34,0x24,0x18,0x0},//0
    
    0x00 00000000
    0x18 00011000
    0x24 00100100
    0x2C 00101100
    0x34 00110100
    0x24 00100100
    0x18 00011000
    0x00 00000000
    
    0x00
    0x18    ##
    0x24   #  #
    0x2C   # ##
    0x34   ## #
    0x24   #  #
    0x18    ##
    0x00
    
    {0x0,0x18,0x14,0x10,0x10,0x10,0x3C,0x0},//1
    
    0x00 00000000
    0x18 00011000
    0x14 00010100
    0x10 00010000
    0x10 00010000
    0x10 00010000
    0x3C 00111100
    0x00 00000000
    
    0x00
    0x18    ##
    0x14    # #
    0x10    #
    0x10    #
    0x10    #
    0x3C   ####
    0x00
    

  • ok I get it. I removed the const and I changed uint8_t for unsigned char

    I thought it was getting "const" the same as using "code" in 8051 microcontroller

    
    
    unsigned char  ascii[128][8];
    unsigned char character_length[128];
    

    but now it throws these errors:

    
    Build target 'Target 1'
    compiling main.c...
    compiling matrix.c...
    linking...
    .\matriztest.axf: Error: L6200E: Symbol ascii multiply defined (by matrix.o and main.o).
    .\matriztest.axf: Error: L6200E: Symbol ascii multiply defined (by matrix_font.o and main.o).
    .\matriztest.axf: Error: L6200E: Symbol character_length multiply defined (by matrix.o and main.o).
    .\matriztest.axf: Error: L6200E: Symbol character_length multiply defined (by matrix_font.o and main.o).
    ".\matriztest.axf" - 4 Errors, 0 Warning(s).
    Target not created
    

    many thanks for your patience

  • "ok I get it. I removed the const and I changed uint8_t for unsigned char"

    Sorry, but you failed to get it.

    Didn't you look for some good book about the C language?

    Why do you think "const" is a keyword that is best to remove?

    Why do you think we got "uint8_t" if it is better to use "unsigned char"?

    What do you think the meaning is of "multiply defined"?