7 years, 8 months ago.

The example code is giving me compiler error 20 and I have no idea why

I literally just imported the library exactly as it is, updated the mbed repository, and it gave me this: http://imgur.com/rZs0YTo

Errors contained in image: Error: Identifier "p15" is undefined in "main.cpp", Line: 6, Col: 14 Error: Identifier "p16" is undefined in "main.cpp", Line: 6, Col: 19 Error: Identifier "p17" is undefined in "main.cpp", Line: 6, Col: 24 Error: Identifier "p18" is undefined in "main.cpp", Line: 6, Col: 29 Error: Identifier "p19" is undefined in "main.cpp", Line: 6, Col: 34 Error: Identifier "p20" is undefined in "main.cpp", Line: 6, Col: 39

Code used:


  1. include "mbed.h"
  2. include "TextLCD.h"

TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); rs, e, d4-d7

int main() { lcd.printf("Hello World!\n"); } </code>

Compiler error 20 tells me "The compiler doesn't recognize the name of a variable or class you are trying to reference", The class is referenced in TextLCD.h;

<code> class TextLCD : public Stream { public:

/ LCD panel format */ enum LCDType { LCD16x2 /< 16x2 LCD panel (default) */ , LCD16x2B /< 16x2 LCD panel alternate addressing */ , LCD20x2 /< 20x2 LCD panel */ , LCD20x4 /< 20x4 LCD panel */ };

/ Create a TextLCD interface

  • @param rs Instruction/data control line
  • @param e Enable line (clock)
  • @param d0-d3 Data lines
  • @param type Sets the panel size/addressing mode (default = LCD16x2)
  • / TextLCD(PinName rs, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, LCDType type = LCD16x2);
  1. if DOXYGEN_ONLY / Write a character to the LCD
  • @param c The character to write to the display
  • / int putc(int c);

/ Write a formated string to the LCD

  • @param format A printf-style format string, followed by the
  • variables to use in formating the string.
  • / int printf(const char* format, ...);
  1. endif

/ Locate to a screen column and row

  • @param column The horizontal position from the left, indexed from 0
  • @param row The vertical position from the top, indexed from 0
  • / void locate(int column, int row);

/ Clear the screen and locate to 0,0 */ void cls();

int rows(); int columns();


Stream implementation functions virtual int _putc(int value); virtual int _getc();

int address(int column, int row); void character(int column, int row, int c); void writeByte(int value); void writeCommand(int command); void writeData(int data);

DigitalOut _rs, _e; BusOut _d; LCDType _type;

int _column; int _row; };

  1. endif </code>

Maybe my programming is rusty, and this is probably something really obvious, but I'm just not getting what is wrong. Can anyone help? Thanks!

Question relating to:

2 Answers

7 years, 8 months ago.

It looks you are using the NUCLEO-F103RB board.
The pin names, p15..20, are for the LPC1768 board.

Why don't you try the pin names of the NUCLEO-F103RB board, such as Px_x, Dx or Ax?

Accepted Answer

That did it, thanks! I appreciate the help, that was driving me nuts. I'm still very new to microcontrollers, and I had just assumed that the names were variables and didn't matter what they were named, I didn't realize that they were keywords for the various pins and specific to each board. My project now moves on!

posted by Matthew Kovach 22 Sep 2015
4 years, 4 months ago.

u need to fix the error with FIX IT command :)