Simple program error after hours of changes

I have a simple code for testing the Serial port usage. I swear I tried the exact code earlier and it functioned properly. So either I'm going blind or there is some other Issue I can't put my finger on.

Any suggestions?

Thanks
John

//Print/Write test to CC2530 as UART (38400)

//*****************************************************************************
// Pin Assignments:
//*****************************************************************************
const int ledPin =  LED_BUILTIN;

// Globals:
//*****************************************************************************
byte ETX=0x03;	// end of text

byte array[]={0x74,0x67,ETX};

// Setup:
//*****************************************************************************

void setup(){
    Serial.begin(38400);
    delay(500);
    pinMode(ledPin, OUTPUT);
}  //  ...setup

unsigned long currentMillis;
unsigned long previousMillis;
uint16_t interval = 10000;


// ================================================================================
// === MAIN LOOP ==================================================================
// ================================================================================

void loop() {

currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
		
        Serial.write(array);
        asm ("sbi %0, %1 \n": : "I" (_SFR_IO_ADDR(PINB)), "I" (PINB5));   // toggle LED
	}
  delay(500);
}  //  .... main loop

// ================================================================================
// === end MAIN LOOP ==============================================================
// ===============================================================================
//  .... eof

I get the following errors:

C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino: In function 'void loop()':
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: error: no matching function for call to 'write(byte [3])'
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233:0,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:129:20: note: candidate: virtual size_t HardwareSerial::write(uint8_t) <near match>
     virtual size_t write(uint8_t);
                    ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:129:20: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned char}' [-fpermissive]
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233:0,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:130:19: note: candidate: size_t HardwareSerial::write(long unsigned int) <near match>
     inline size_t write(unsigned long n) { return write((uint8_t)n); }
                   ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:130:19: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'long unsigned int' [-fpermissive]
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233:0,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:131:19: note: candidate: size_t HardwareSerial::write(long int) <near match>
     inline size_t write(long n) { return write((uint8_t)n); }
                   ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:131:19: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'long int' [-fpermissive]
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233:0,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:132:19: note: candidate: size_t HardwareSerial::write(unsigned int) <near match>
     inline size_t write(unsigned int n) { return write((uint8_t)n); }
                   ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:132:19: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'unsigned int' [-fpermissive]
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233:0,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:133:19: note: candidate: size_t HardwareSerial::write(int) <near match>
     inline size_t write(int n) { return write((uint8_t)n); }
                   ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:133:19: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'int' [-fpermissive]
         Serial.write(array);
                           ^
In file included from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Stream.h:26:0,
                 from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/HardwareSerial.h:29,
                 from C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:233,
                 from C:\Users\John\AppData\Local\Temp\arduino-sketch-06CB6ED0543AF21AB9F890A5349A424D\sketch\CC_UART_02.ino.cpp:1:
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Print.h:52:12: note: candidate: size_t Print::write(const char*) <near match>
     size_t write(const char *str) {
            ^~~~~
C:\Users\John\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Print.h:52:12: note:   conversion of argument 1 would be ill-formed:
C:\Users\John\Documents\Arduino\UART-cc2530\CC_UART_02\CC_UART_02.ino:38:27: warning: invalid conversion from 'byte* {aka unsigned char*}' to 'const char*' [-fpermissive]
         Serial.write(array);
                           ^

Compilation error: exit status 1

try with this:

Serial.write(array, sizeof array);

array is actually a pointer. The overloads of the write() method that only take one parameter do not take a pointer type.

@J-M-L is correct. Try:

Serial.write(array, sizeof (array));

This overload of write() takes a buffer pointer and a size.

Thank you both for your answers. I had the sizeof originally but is seemed to work without the sizeof. I guess I must have mixed my results data :frowning:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.