Serial Read Issue

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JPF100
 
Posts: 17
Joined: Mon Sep 12, 2022 11:10 am

Serial Read Issue

Post by JPF100 »

Hello,

I have been able to write to the serial port window (Grand Central M4 (SAMD51 on 'COM6') in the Arduino IDE 2.0.0. I am not however able to read from this window. When I perform a Serial.available command and provide a return variable, then print this variable, it returns a 0. I know this variable changes as I initialize it as 50 when I start. It should return a 1. In Setup I use a Serial.begin(9600) and while(!Serial) command(s). I studied an Adafruit tutorial on this subject and can't seem to find a solution. Any help would be appreciated. All feedback was via the serial window within the Arduino environment. Using MS Windows 10.

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Serial Read Issue

Post by adafruit_support_carter »

available() only returns the number of bytes available for reading. You'd then call read() to actually read the value.

See basic example here:
https://www.arduino.cc/reference/en/lan ... available/

User avatar
JPF100
 
Posts: 17
Joined: Mon Sep 12, 2022 11:10 am

Re: Serial Read Issue

Post by JPF100 »

Thank you very much. That worked!

User avatar
JPF100
 
Posts: 17
Joined: Mon Sep 12, 2022 11:10 am

Re: Serial Read Issue

Post by JPF100 »

From you help, I was able to create a language independent VERY simple serial CLI to manipulate all of the DIO on the Grand Central. Onward to SPI!

User avatar
JPF100
 
Posts: 17
Joined: Mon Sep 12, 2022 11:10 am

Re: Serial Read Issue

Post by JPF100 »

I am now working on simple SPI interface. I have 2 GCs connected in a master/slave or controller/peripheral configuration. I am using the Arduino environment. I have been able to transmit from the controller to the peripheral, but I want to be able to read the transmitted byte from the controller on the peripheral side and display it on the peripheral's serial port console. I setup the peripheral using a series of SERCOM1 commands. This setup enables interrupts on the peripheral side of things. I successfully read back the data on the controller side. I confirmed that all of the lines are setup correctly with an oscilloscope. I also confirmed with a scope that the data being transmitted back to the controller is correct on the CIPO line with the clock. Any help would be appreciated.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”