Implement a virtual Instrument (MIDI OUT) on STM32, Note-On not works - stm32

I'm implementing a virtual instrument on STM32 (STM32F103x). Like a normal "hello world", I tried to start with the simplest MIDI message, sending NOTE-ON MIDI message in a loop to see if it works.
I send MIDI NOTE-ON message for every 500ms, only NOTE-ON message in a forever loop, but it not works. Is there any other MIDI message must be sent to make MIDI works? Like some initialize message?
Based on MIDI 1.0 spec, I finish my code on STM32 by sending MIDI message via USART interface.
Then use a logical analyzer, I confirmed my MIDI message is fully match the MIDI 1.0 spec. At least I believe it correct, no issue. 31250 baud rate, 1 start bit, 1 stop bit, one status message 0x92 followed by two data bytes 0x48 and 0x7F, LSB first.
Below is the NOTE-ON message captured by the logical analyzer on TX line of URAT interface. I continue send the same 3 bytes for every 500ms.
The totally time for those 3 bytes are 960 microseconds also match MIDI 1.0 spec mentioned value.
Then, based on "(CA-033) MIDI 1.0 Electrical Specification Update [2014]", I buy one 5 PIN MIDI OUT jack, connect the URAT TX line to PIN-5 through a 10 Ohm resister, connect 3.3V power to Pin-4 through a 33 Ohm resister, PIN-2 and Jack shield connect to GND. Other optional parts (buffer for Rc, ferrite beads) are not used.
However, when I use a USB-MIDI wire connect my MIDI OUT jack to my PC, nothing happen. The USB-MIDI wire has two LED indicators , one for power another for MIDI signal. After connect, the power LED is light, but the MIDI signal LED never light.
I tried to use logical analyzer to analysis PIN-5 of my MIDI OUT jack, the MIDI message byte are totally same with URAT TX line, and every 500ms one NOTE-ON message. However, it never works.
I also tried to create my own PCB with Dream SAM2695 by follow the SAM2695 Evaluation Boards. Then connect the URAT TX directly to MIDI_IN pin of SAM2695, it still no response. Since I have no confidence on my manual soldering PCB, not sure if the PCB itself has issue cause it no response. So I buy a USB-MIDI wire, but the result as I mentioned above, still no response.
======= Apr.26.2021 Update =========
Based on comments, have tried to check the output of the optocoupler.
Before do this check, I bought several BSS138 to transform the MIDI signal to 5V single use below circuit (of course change the resisters near MIDI JACK pin to 220 Ohm as the spec)
After this change I measured voltage of the 5V URAT TX, it show as 4.8+ V, and Logical Analyzer show correct MIDI note on message of this new 5V MIDI signal. However, it still not works.
The only left troubleshooting method for me is measure the output of the optocoupler on this USB-MIDI wire. But I didn't find an optocoupler on this MIDI USB wire PCB. There even do not have any one component has 4 pins on the PCB (based on my understanding, an optocoupler need at least 4 pins).
There only have one main chip on the PCB, it is possible that the optocoupler is embedded in that chip? Since the pin are too small I failed to connect my logical analyzer to those pin to check.

Related

The relationship between RGMII to MDI in Ethernet communication

Let's say I am talking to a PHY chip via RGMII.
What is the relationship between the serial information transmitted on the RGMII to the signals that go out to the MDI?
I understood from the timing diagram of RGMII that the rising edge is 4 bits and the falling edge is 4 bits. So for each clock that gives 8 bits.
For 100Mbps, the clock required is 25MHz. So for every 25MHz clock cycle, 8 bits are transmitted.
Does the PHY chip simply send each 8 bits over the MDI immediately?
If that is the case, then how do I correctly package these serial 8 bits of data into a proper ethernet frame?
I a trying to troubleshoot a piece of hardware where the PHY does not work properly but the only way troubleshoot is if I can control the RGMII. However, I do not understand this relationship between the RGMII and how it affects the MDI.
I presume that if I look at wireshark, it will not show any packets of information unless I send a string of serialized data in a proper Ethernet frame.
The PHY should have some documentation and sample code. Without, finding out how exactly it works can be a very tedious task.
You can find the general RGMII description here: https://web.archive.org/web/20160303212629/http://www.hp.com/rnd/pdfs/RGMIIv1_3.pdf

SPI MISO-MOSI signal are the same on oscilloscope

I try to read a memory cell from a chip with my stm32f103 uC. I send three bytes, one instruction then 2 address bytes. Watching this on a scope I get the MOSI signals back, not the same level, but attenuated. Is that normal? If something's wrong with my chip, should the MOSI signal reflect back on the MISO pin?
You need to send more than 3 bytes master generates the clock. To read something master needs to send dummy bytes.

How to sync microcontroller to MIDI controller output

I am looking to receive MIDI messages to control a microcontroller based synthesizer and I am working on understanding the MIDI protocol so I may implement a MIDI handler. I've read MIDI is transmitted at 31.25kHz without a dedicated clock line - must I sample the line at 31.25kHz with the microcontroller in order to receive MIDI bytes?
The MIDI specification says:
The hardware MIDI interface operates at 31.25 (+/- 1%) Kbaud, asynchronous, with a start bit, 8 data bits (D0 to D7), and a stop bit. […] Bytes are sent LSB first.
This describes a standard UART protocol; you can simply use the UART hardware that most microcontrollers have built in. (The baud rate of 31250 Hz was chosen because it can be easily derived from a 1 Mhz (or multiple) clock.)
If you really wanted to implement the receiver in software, you would sample the input signal at a higher rate to able to reliably detect the level in the middle of each bit; for details, see What exactly is the start bit error in UART? and How does UART know the difference between data bits and start/stop bits?

Reading PWM signals in STM32F407

I am doing a quadcopter using a STM32F407 discovery. I was finally able to stabilize it. Now i am trying to use the RC receiver so i can control my quadcopter movements. Is there a way to read the signal of PWM of my RC receiver channels ??
Also my RC receiver supports PPM and according to what i understand it receives a packet of duty cycles strong textbut still don't know how to receive this.
You can use the SPI interface to encode the PPM (or the PWM) signal of your RC receiver.
General approach:
Connect the PPM signal to the MISO pin and a second one of the controller (simultaneously). MOSI, CLK, and CS pins are not needed.
Initialize the SPI interface with a appropriate clock. With this frequency the signal will be shifted in the controller. Try to use 4kHz.
Depending on the idle state of the signal enable either rising or falling edge interrupt trigger on the second pin. This will used to trigger incoming frames.
If the interrupt occurs disable the trigger temporary and start spi transmission to get several bytes (outgoing ingored and not connected). Depending on the Frame length 8 or 10 Bytes should do it. This will catch frames up to 20ms.
After you get the all bytes enable the trigger again and repeat for the next frame.
The received data should contain the pattern of the pwm/ppm signal.
You should also match the sampling rate and the amount of bytes to receive with your RC receiver.

Serial Port Communication understanding

i need some help understanding a specific serial port connection from a sensor. I need to read data from the sensor and make some calculations in matlab or c++ (i will decide later)
The manufacturer only gives a chart with the following details:
Sensor Serial Port
Pin Number Mode Pin Description
I Trigger Input
I RS-232 Receive
O RS-232 Transmit
PWR Sensor Power (DTR)
PWR/GND Signal Ground
Not Used (Reserved)
Not Used (Reserved)
I/O RS-485 B Signal Pin
I/O RS-485 A Signal Pin**
So my question is: OK i know that pin 2 is used to receive data but how am i going to decode the volts stream into integers for example for my program? Also, i know that pin 4 gives power to the sensor. How do i know how many volts it has to give? Generally how am i going to learn all these details since the manufacturer does not give it?
Do you think Serial Port Analyzer Software will help?
Thanks very much in advance.
You might want to search for "DE-9 pinout YourSensorNameHere" in google or This page might be of some use to you. With most RS-232 you only need pins 2,3 and 5. With out more specifics about your sensor there isn't much SO can do for you.