Go Down

Topic: Serial was not declared for this scope error on an 8515 (Read 3638 times) previous topic - next topic

somedude

Hello,


I followed WestfW's instructions in a different post to find detailed info about the compile error, to no avail.
It points to the same line of the sketch.
The line that throws the error is Serial.begin(9600) in the setup.

The problem is that I am trying to compile a very simple sketch, like blink, but with serial output.
None of that would be normally a problem, except I am trying to do this on an AT90S8515, which does have an UART on pins PD0/10 and PD1/11.

It is obvious to me that I am using an unsupported MCU and I am expecting the Arduino IDE 1.6.5 to "just work". For the Uno or Nano I didn't have to include any library to get Serial to work, but the 8515 didn't like it.

This is my code:
Code: [Select]
void setup() {
  Serial.begin(9600);
}

void loop() {
}


And this is the error:
error: 'Serial' was not declared in this scope

I have no idea where to look for the setup. Well, I have an idea, since the only file I needed to add was pins_arduino.h, I have a hunch that this is where something is missing, possibly a declaration for the serial pins, something like that.
Comparing my pins file with existing (standard) Arduino pins files didn't give me any clues as to what might be missing.

If anyone could point me in the right direction, I would very much appreciate it.
Thank you

Delta_G

There are a few other files.  A chip specific version of ioxxxx.h for starters to include the Serial instance.  There are cores for other chips out there, the attiny85 comes to mind as having a good one.  You might find one for that chip or you might need to look at one of those as an example and write your own.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

somedude

Thank you Delta.

There is an io8515.h file part of the core Arduino IDE, but I expected it to be accurate, or it would have been reported by now.
I will, however, check it.

By comparing other pins_arduino.h with mine I found references that define a couple of constants as 'Serial' but not the Serial object definition as such. I am hoping that you are right and since this chip is so old, nobody bothered to report it.

Thanks again.

Delta_G

I think the actual definition of the Serial object happens in HarwareSerial.cpp

Here:

Code: [Select]

// Preinstantiate Objects //////////////////////////////////////////////////////

#if defined(UBRRH) && defined(UBRRL)
  HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
#elif defined(UBRR0H) && defined(UBRR0L)
  HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
#elif defined(USBCON)
  // do nothing - Serial object and buffers are initialized in CDC code
#else
  #error no serial port defined  (port 0)
#endif

#if defined(UBRR1H)
  HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1);
#endif
#if defined(UBRR2H)
  HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2);
#endif
#if defined(UBRR3H)
  HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
#endif



It appears to decide based on a register or a bit in a register having its name defined.  If your chip has that register defined in a different way then this may not line up and create an object for you.  HarwareSerial is pretty well documented though, it shouldn't be hard to go through and find the places where you have to make chip dependent decisions and you can create your own instance in your sketch.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

somedude

Thanks again, Delta.

The data sheet for 8515 doesn't have any reference to these registers, only UBRR, which is the data rate.
I will do some more research to see where these registers are defined for the, say 328, and compare.

somedude

Update:

I compared mega8515 with my s8515 and it appears the s has separate status and control registers as opposed to the mega.
Would it be possible to change the references in io8515.h or is it easier to add another if in the HardwareSerial file as shown above?

In io8515.h I could add:
#define UBRRL UBRR
#define UBRRH UBRR
Would that work? I would then try to remap to UCSRA and UCSRB.

Thank you

somedude

Not a good solution, after going through the data sheets, that was the wrong approach.

I seem to be better of putting a new if in HardwareSerial, as I noticed exceptions in there for ATtiny.
The problem seems to be indentifying the parameters for the function call.

I am way over my head here and I can't think of another way to troubleshoot my sketches on this 8515.

mintoo

hey buddies ,
im new to arduino programming..
i have connected labview with arduino mega.. and im sending string data serially from labview to arduino..now i want to send "yes" if and only if arduino recievs "ready...!" at serial com port else i want to send NO. can any1 provide me code please im stucked here.. !!

void setup()
{(Serial.available = (Serial.read));

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  //  while (!Serial) {
  //    ; // wait for serial port to connect. Needed for native USB port only
  //  }
 
      if (Serial.available=(READY))

  {
    serial.write(YES);
  }
  else
  {serial.write(NO)
  }
}


i have tried this at my level

PaulS

Code: [Select]
{(Serial.available = (Serial.read));

(What) (the) (heck) (are) (all) (the) (parentheses) (for) (?)

Code: [Select]
      if (Serial.available=(READY))
The function available() has an address. The address is unlikely to be stored in the symbol READY (whatever that is). You can NOT assign a value to the function, anyway.

Go look at some more examples. Study (where) there are (parentheses). Understand WHY there are parentheses. Understand that you MUST define all symbols. READY, YES, and NO are not defined.

Quote
im stucked here.
You are something that rhymes with stucked, but you are not stucked (which isn't even a word).
The art of getting good answers lies in asking good questions.

Roshan45


Go Up