SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By acug
#198665
When using the s/f MIDI shield, the default serial connection is h/w to pins 0 and 1. If I access this in a sketch, it seems that the USB serial is active at the same time, i.e., data written to one is also written to the other. Questions:
1. Does h/w serial always use both the USB and h/w pins 0, 1? If so, how is data to be read from the interface handled (differentiated) between the two?
2. Is there a way to run each h/w interface separately?
3. Can I use s/w serial on pins 8, 9 and h/w serial on pins 0, 1, each with different communications?

Thanks!
By paulvha
#198667
1. Yes. that is hard wired. Only by using the switch that is on the board (see hookup guide) you can share H/W serial
2. no, only with the switch
3. yes. they are separated and work independent.
By paulvha
#198670
The switch ONLY disconnect the hardware RX. The TX is not switched and also connected through the solder pads. To set the RX/input to s/w you will have to "play"with SJ1 and SJ2 solder pats. SJ1 determines the RX, where the SJ2 determines the TX. By default the middle solder-pad is connected to the hardware pin (0 or 1). You will have to cut out the link in SJ1 between the 2 (very carefully with a sharp knife like a Stanley mess) and then solder a connection between the middle pad and and the other pad. (see the schematics and hookup guide)
By acug
#198671
Thanks, I got the mechanics of it.

So, the rcv side (SJ1) can be switched hard or soft (and then read using the appropriate call), but the xmit side (SJ2), if set to hard, will always send to pin 1 and USB, or if set to soft, will send to pin 9 (again, using the appropriate call).

Is that right?
By paulvha
#198674
I took another look at the schema.

Pin 0/rx is going to the switch (run/prog). When set to "run" it is then connected with right pad of the SJ1, which is by default connected with a tin line to the pad in the middle. If you want to use SoftSerial pin 8 instead, cut the thin line and connect the left pad with the middle.

Pin 1/tx is connected with the right pad of SJ2, which is by default connected with a tin line to the pad in the middle.If you want to use SoftSerial pin 9 instead, cut the thin line and connect the left pad with the middle.

regards,
Paul
By acug
#198680
The schematic is clear; what is not is the internals of the ATmega chip.

What I get from our discussion is this:

Writing data:
1. Making a call to Serial.write will write data to both Pin 1 and the USB. This cannot be changed.
2. MIDI out connector (J2) will get data from either Pin 1 (hard) or Pin 9 (soft), depending on how SJ2 is set; the default is "hard."
3. Writing data to Pin 9 requires a different call, e.g., SoftwareSerial.

Reading data:
4. Making a call to Serial.read will read data from both Pin 0 and from the USB??? This is the condition that is not clear.
5. MIDI in connector (J1) will send data to either Pin 0 (hard) or Pin 8 (soft), depending on how SJ1 is set; the default is "hard."
6. Reading data from Pin 8 requires a different call, e.g., SoftwareSerial.

Now you see my open issue. Thanks for the discussion.
By paulvha
#198682
The RX and TX for the USB (coming from the ATMEGA16U2 to which the USB is connected) are hardware connected with a resistor to the pin 0 and pin 1. The ATMEGA328 does not have a separate USB connection. Whatever is received on P0 is automatically going to both the ATMEGA328 and the USB.
Regards,
Paul
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]