Midi component ohne Funktion

Support-Forum für Deutschsprachige, die in ihrer Muttersprache schreiben möchten.

Moderator: Benj

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Midi component ohne Funktion

Postby DirkB » Thu Mar 01, 2012 10:43 am

Hallo,

das mit dem Timing für 8 Mhz (osccon = 0x70) funktioniert und 1 Sekunde ist 1 Sekunde. Nun gibt es ein
Problem mit Midi. Es scheint das gleiche Problem wie hier:

viewtopic.php?f=46&t=10325

Ich verwende im Moment den 16F684 mit Interrupt und Software USART. Das funktioniert nicht. Nun wechsle
ich auf den 16F688 mit Hardware EUSART. Dazu habe ich das gefunden:

There are some good solid reasons for my choice (and many others) of the PIC (AVR) when useing MIDI. Firstly, it has a built HARDWARE UART, this means no messing with 'bit bashing' and constantly reading ports. Secondly, it's interupt driven! This means the AVR can be doing other things, and not worry about MIDI data until it arrives. Thirdly, it's quick! At 8MHz you can get nearly 8 MIPs. Processing of MIDI data can get quite complex, and with a large system you can have an almost constant stream of data to work with, so it needs to be quick and decide which bytes it wants to use and which it does not care about.

Wird das von Flowcode V5 unterstützt? Was muss ich tun um den Interrupt des EUSART zu erhalten?

Regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Thu Mar 01, 2012 11:32 am

Hello Dirk,

Please see the other topic you mentioned for a fix for the software UART receive.

viewtopic.php?f=46&t=10325

To put the MIDI component into hardware mode you will have to use the code customisation feature.

Select the MIDI component on the panel and click custom code, select the Defines function and click edit code, finally find this line

#define MX_UART_CHANNEL_1 %b

and change to this

#define MX_UART_CHANNEL_1 x

Where x is the UART channel you wish to use.

0 = Software Bit Banged - Default
1 = UART 1
2 = UART 2 if available

If you wish to use UART RX interrupts then as long as you have switched the defines to a hardware UART you can include the RXINT interrupt into your program using an interrupt icon. Inside the interrupt macro call the receive midi macro and the interrupt should fire as soon as a MIDI packet starts to be received.

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Fri Mar 02, 2012 10:58 am

Hi Ben,

yesss, ich habe das neue PIC_CAL_UART.c installiert und nun scheint der
Software UART zu funktionieren. Ich werde noch testen und berichten.

Thanks

Dirk

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Fri Mar 02, 2012 2:10 pm

Hello Ben,

ich habe etwas getestet und nun folgende Probleme. Bei Kompilieren bekomme ich folgende Warnungen:

Serious Warning: Possible sw stack corruption, function 'FCD_MIDI0_ReceiveMIDI' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_MIDI0_ReadData' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_EEPROM0_EEPROMRead' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'delay_ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

Diese Warnung bekomme ich nur wenn Receiving Midi in einem Makro aufgerufen wird. Ist es im Hauptprogramm gibt es keine Warnung.

Ich empfange Program Change via Midi. Ich benötige nur das Statusbyte und das 1. Databyte. Die empfangene Programmnummer (1. Datenbyte) wird die
Adresse um das EEProm auszulesen. Es werden auch nur 2 Bytes vom Sender gesendet. Das Wort ist also nach 2 Bytes komplett. Der UART erwartet aber
3 Worte. Kann man das einstellen, oder ist das egal?
Bei den ersten 4 Programmnummer funktioniert alles einwandfrei. Die ungeraden Programmnummer, vor allem 5 und 9 geben permanent unvorhersehbare
Werte in die Variable. Das ändert sich dramatisch durch ändern des Receiving Timeout. Es gibt keinen Wert für das Timout der wirklich funktioniert.
Ich denke das Status Byte und die Datenbytes werden nicht korrekt gelesen. Ein Timout grösser als 12 kann ich nicht verwenden. Dann wird die Komunikation
zu langsam. Besser ist ein Timout von maybe 4 Byte. Das sind momentan die letzten Probleme für mich! Any Ideas?

Regards

Dirk
Last edited by DirkB on Sun Mar 04, 2012 10:40 am, edited 3 times in total.

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Sat Mar 03, 2012 11:50 am

Hello Ben,

after editing custom code there is no RXINT interrupt available.? What's going wrong?

Benj wrote:
If you wish to use UART RX interrupts then as long as you have switched the defines to a hardware UART you can include the RXINT interrupt into your program using an interrupt icon. Inside the interrupt macro call the receive midi macro and the interrupt should fire as soon as a MIDI packet starts to be received.


Regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Mon Mar 05, 2012 10:54 am

Hello Dirk,

What chip are you using? And are you using the UART in hardware or software mode?

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Mon Mar 05, 2012 11:37 am

Hello Ben,

i am using 16F684, 16F688, 16F88 and 16F917, Software UART with internal OSC 8 Mhz at the moment. Will change to hardware UART if necessary.

Thanks

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Mon Mar 05, 2012 12:51 pm

The RXINT interrupt will only work with hardware UARTs and will be more reliable as the hardware can buffer up to 3 bytes of data rather then the software which will just error if you happen to miss any of the data start bits.

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Mon Mar 05, 2012 2:14 pm

Hi Ben,

i have testet Hardware UART with 16F688 but in Interrupt Icon ist no RXINT present.

Regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Mon Mar 05, 2012 5:26 pm

Hi Dirk,

Right looking at the datasheet for the 16F688 device it seems it is one of the very early Microchip PIC devices where they were just starting to add interrupt functionality to everything. It looks like the UART on this device is capable of TXINT or RXINT type interrupts so hopefully I can get this missing interrupt added to the list for you.

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Mon Mar 05, 2012 5:37 pm

HI Dirk,

Right here is an updated FCD file for v5.1 that should now have the receive interrupt available.

16F688.fcd
(8.14 KiB) Downloaded 620 times


Simply place the file into your "Flowcode/v5/FCD" directory before starting Flowcode.

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Tue Mar 06, 2012 3:37 pm

Hi Ben,

16F688 with Hardware UART works well. Thank you so much. Now i can finish my Projects.
Are Updates for other Chips (16F917 and so on) available? Is it possible to fix Timing Problem
of Software UART?

Regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Tue Mar 06, 2012 5:04 pm

Hello Dirk,

Great glad it is working correctly for you now.

Are Updates for other Chips (16F917 and so on) available?


What kind of updates? Is the RXINT interrupt missing from this device? Most of the devices should be correct so let me know any specific problems and I will look into fixing them.

Is it possible to fix Timing Problem of Software UART?


I wasn't aware there was a timing problem with the software UART. I am aware however that there is a much bigger chance of missing data using the software UART. The only time a software UART can really be relied upon is if you are either only sending data out or if you also have something like a INT or IOC interrupt which is triggered whenever the receive signal is pulled low to ensure you never miss a start bit.

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Tue Mar 06, 2012 5:45 pm

Hi Ben,

ok, i understand. I don't have tested other Chips. Is it possible to separate upper nybble and lower nybble from Status Byte in two Variables?

Thanks

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Tue Mar 06, 2012 6:05 pm

Hi Dirk,

It sure is...

lowernib = status & 0x0f
highernib = (status & 0xf0) >> 4

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Wed Mar 07, 2012 12:32 pm

Hi Ben,

Benj wrote:It sure is...

lowernib = status & 0x0f
highernib = (status & 0xf0) >> 4


thank you. These code must be used in a calculation Icon?

When using Hardware UART it is reading LSB first. Does the Midi Component reading Status Byte (data 0) LSB first too?
There is a tiny problem with status byte with different Hardware Controller. Not all Controller works well.

Regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Wed Mar 07, 2012 1:48 pm

Hello,

Yes you can use the code in a calculation icon with variables named status, lowernib and highernib.

The MIDI component and all other UART based components read the data LSB first.

Can you be more specific about the status byte problem. What is going wrong, how did you find this, is there a way of replicating this, are there devices that work and devices that don't, etc...

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Wed Mar 07, 2012 3:18 pm

Hello Ben,

i stored a Status Byte manually in EEprom. In this case it is 0xC0, C for Programm Change, 0 for Midi Channel 1.
In Flowchart reading this into variable Midi_Chan. After incoming Midi Massage the Status is stored with Midi Component
"MidiReceive" into the variable "Status". Then i use the decision "Status = Midi_Chan?". This should process only Program Change
on Midi Channel 1. This doesn't works.
I have a "Midi Learn Funktion" implemented. This stores read Status Byte from Midi In to EEprom. Then with my TC-Electronic Foot Board works well,
with another Controller it doesn' t works correct at all time.
After processing Midi a LED will flash. This LED flash on Volume Data, Active Sensing, Drawbars, Notes, etc. too. Not only while Program Change.
I don't know what going wrong. Problem with Start/Stop Bit in Status Byte maybe. The Status Byte is 10 bit. It is certain that the status is not interpreted correctly.
I hope you understand my bad english :roll:

Regards

Dirk

Edit:
Now I have checked the Midi Data to a MIDI Monitor. The Midi Controllers Data are right!!!!

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Fri Mar 09, 2012 6:38 pm

Hello,

someone an idea???

(Edit)

I found it.

The V4 examples are wrong!

It must be:

- Receive Midi into variable "MidiIn"
- Read Data 0 into variable "status" (very important to get status byte)
- Read Data 1 into variable data1
- Read Data 2 into variable data2

This works very well.

Regards

Dirk
These users thanked the author DirkB for the post:
Benj (Mon Mar 12, 2012 10:47 am)
Rating: 5.26%
 

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Sun Oct 28, 2012 1:31 pm

Hello,

is it possible to increase buffer of Software Uart up to 3 bytes or 6 bytes maybe?

thanks

DirkB

DirkB
Posts: 107
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: Midi component ohne Funktion

Postby DirkB » Mon Nov 19, 2012 9:25 pm

Benj wrote:The RXINT interrupt will only work with hardware UARTs and will be more reliable as the hardware can buffer up to 3 bytes of data rather then the software which will just error if you happen to miss any of the data start bits.


Hello Benj,

is it possible to increase Software UART up to 3 Bytes or more?

regards

Dirk

User avatar
Benj
Matrix Staff
Posts: 14370
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Midi component ohne Funktion

Postby Benj » Tue Nov 20, 2012 11:24 am

Hello Dirk,

The only way to increase the reliability of the software UART is to use an external falling edge interrupt on the incoming RX signal to detect the start bit and call the receive function. The buffer size cannot just be increased as there is no hardware buffer, you have to be there listening to pick up the data as it comes in.