How to print return data without serial.print?

I can’t use serial.print because it conflict with my unique serial communication.

but I want to know the return value of my function “SPI_Transfer” and print it on the PC screen just like C language.

How can I do that?

Thanks.

/* Fake SPI Initialise Function Based on UART. NOT the SPI Library in the Arduino System */
void SPI_Initialise() {
  
  pinMode(DCLpin,OUTPUT); // MOSI: Camera to Lens
  pinMode(LCLKpin,OUTPUT); // LCLK pin
  pinMode(SSpin,OUTPUT); // SS pin
  pinMode(DLCpin,INPUT); // MISO: Lens to Camera
  
  //Set UART as SPI.
  UBRR0 = 0;
  UCSR0C = (1<<UMSEL01)|(1<<UMSEL00)|(1<<UCPHA0)|(1<<UCPOL0);  //Set to MasterSPI (UMSEL0=1, UMSEL1=1), in Mode3 (CPHA=1, CPOL=1)
  UCSR0B = (1<<RXEN0)|(1<<TXEN0); //Enable TX and RX (TX = MOSI, RX = MISO)
  
/* clock rate: UBRR0 = (FCPU/(2*BAUD)) -1; 
for 62.5kHz or 16us pulse, UBRR0 = (16000000/(2*62500))-1 = 127; 
for 76.9kHz or 13us pulse, UBRR0 = (16000000/(2*76900))-1 = 103;
*/
  UBRR0 = 127;
}

/* Fake SPI Protocol Function Based on UART. NOT the SPI Library in the Arduino System */
byte SPI_Transfer(byte data) {
  
  /* Wait for empty transmit buffer */
  while ( !( UCSR0A & (1<<UDRE0)) );
  
  /* Put data into buffer, sends the data */
  UDR0 = data;
  
  /* Wait for data to be received */
  while ( !(UCSR0A & (1<<RXC0)) );
  
  /* Get and return received data from buffer */
  return UDR0;
}

1st function will be in the void setup()
2nd function will be used in the void loop()

these are the unique serial communication. when I tried using Serial.print, it will conflict with my serial function.

Software serial and a TTL to RS232 / USB converter.

SoftwareSerial - serial to usb converter - computer = hyperterminal or similar program.

jenaflex: I can't use serial.print because it conflict with my unique serial communication.

You probably need to explain what your "unique serial communication" is before anyone can give you a meaningful answer.

/* Fake SPI Initialise Function Based on UART. NOT the SPI Library in the Arduino System */
void SPI_Initialise() {
  
  pinMode(DCLpin,OUTPUT); // MOSI: Camera to Lens
  pinMode(LCLKpin,OUTPUT); // LCLK pin
  pinMode(SSpin,OUTPUT); // SS pin
  pinMode(DLCpin,INPUT); // MISO: Lens to Camera
  
  //Set UART as SPI.
  UBRR0 = 0;
  UCSR0C = (1<<UMSEL01)|(1<<UMSEL00)|(1<<UCPHA0)|(1<<UCPOL0);  //Set to MasterSPI (UMSEL0=1, UMSEL1=1), in Mode3 (CPHA=1, CPOL=1)
  UCSR0B = (1<<RXEN0)|(1<<TXEN0); //Enable TX and RX (TX = MOSI, RX = MISO)
  
/* clock rate: UBRR0 = (FCPU/(2*BAUD)) -1; 
for 62.5kHz or 16us pulse, UBRR0 = (16000000/(2*62500))-1 = 127; 
for 76.9kHz or 13us pulse, UBRR0 = (16000000/(2*76900))-1 = 103;
*/
  UBRR0 = 127;
}

/* Fake SPI Protocol Function Based on UART. NOT the SPI Library in the Arduino System */
byte SPI_Transfer(byte data) {
  
  /* Wait for empty transmit buffer */
  while ( !( UCSR0A & (1<<UDRE0)) );
  
  /* Put data into buffer, sends the data */
  UDR0 = data;
  
  /* Wait for data to be received */
  while ( !(UCSR0A & (1<<RXC0)) );
  
  /* Get and return received data from buffer */
  return UDR0;
}

1st function will be in the void setup()
2nd function will be used in the void loop()

these are the unique serial communication. when I tried using Serial.print, it will conflict with my serial function.

1st function will be in the void setup()
2nd function will be used in the void loop()

It is not terribly helpful not posting all the code.
What you meant to say was “I am using the hardware UART for generating another SPI interface”, although why I don’t know because several devices can be chained on the hardware SPI interface.

So the answer remains what I said in #1, and what cyclegadget said in #2