Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

greg79
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

The following MIDI project is a simpler version of the 'MIDI Piano' project. What I need at the moment is blinking an LED when the host sends any MIDI Sysex message. However, when I plug the board into the host PC, I get the following error message: 

MIDI_memory_error.png

When I comment out the MIDI identity reply part (as in the MIDI Piano project), I don't have this problem however the host PC does not recognise the MIDI device. What am I missing?

#include "project.h"
#include <stdlib.h>
#include <stdio.h>
#include <USBMIDI1_midi.h>
#define BlinkLED(); {Pin_LED_Write(1); CyDelayUs(3); Pin_LED_Write(0);} // blink LED indicator


//===========================================
// Global variables
//===========================================
char buff[32];//output UART buffer

#define DEVICE                  (0u)
#define MIDI_MSG_SIZE           (4u)


// Identity Reply message 
const uint8 CYCODE MIDI_IDENTITY_REPLY[] = {
    0xF0u,          // SysEx 
    0x7Eu,          // Non-real time 
    0x7Fu,          // ID of target device (7F - "All Call") 
    0x06u,          // Sub-ID#1 - General Information 
    0x02u,          // Sub-ID#2 - Identity Reply 
    0x7Du,          // Manufacturer's ID: 7D - Educational Use 
    0xB4u, 0x04u,   // Family code 
    0x32u, 0xD2u,   // Model number 
    0x01u, 0x00u, 0x00u, 0x00u, // Version number 
    //0xF7          //End of SysEx automatically appended 
};
 
//extern volatile uint8 USB_MIDI1_InqFlags; // Need for Identity Reply message



void Init()
{
    CyGlobalIntEnable;

   // USBMIDI_1_Start(DEVICE, USB_DWR_VDDD_OPERATION);  // Start USBFS device 0 with VDDD operation
    USBMIDI1_Start(DEVICE, USBMIDI1_DWR_POWER_OPERATION);
    CyDelay(20);

}


//==============================================================================
// Function Name: main
//==============================================================================
// Summary:
//       1. Starts the USBFS device and waits for enumaration.
//==============================================================================
int main()
{

    Init();

    while(1u) // forever
    {
        /* Host can send double SET_INTERFACE request */
        if(0u != USBMIDI1_IsConfigurationChanged())
        {
            if(0u != USBMIDI1_GetConfiguration())   // Initialize IN endpoints when device configured
            {
                USBMIDI1_Init(); // Enable output endpoint
            }
        }        
        
        // Service USB MIDI when device is configured
        if(0u != USBMIDI1_GetConfiguration())    
        {
            // Call this API from UART RX ISR for Auto DMA mode
            #if(!USB_EP_MANAGEMENT_DMA_AUTO) 
                USBMIDI1_MIDI_IN_Service();
            #endif
            
            // In Manual EP Memory Management mode OUT_EP_Service() 
            //  may have to be called from main foreground or from OUT EP ISR
            #if(!USBMIDI1_EP_MANAGEMENT_DMA_AUTO) 
                USBMIDI1_MIDI_OUT_Service();
            #endif
            
   //          Sending Identity Reply Universal System Exclusive message back to computer 
            if(0u != (USBMIDI1_MIDI1_InqFlags & USBMIDI1_INQ_IDENTITY_REQ_FLAG))
            {
                USBMIDI1_PutUsbMidiIn(sizeof(MIDI_IDENTITY_REPLY), (uint8 *)MIDI_IDENTITY_REPLY, USBMIDI1_MIDI_CABLE_00);
                USBMIDI1_MIDI1_InqFlags &= ~USBMIDI1_INQ_IDENTITY_REQ_FLAG;
            }
        }
        
        
    }
}

//void USBMIDI1_callbackLocalMidiEvent(uint8 cable, uint8 *midiMsg) CYREENTRANT
//{
//    BlinkLED();
//    cable = cable; // to avoid a warning message (var not used..)  
//    *midiMsg = *midiMsg;
//}  


//==============================================================================
// Function Name: USB_MIDI1_ProcessUsbOut_EntryCallback
//==============================================================================
// Summary:  Turn the LED_OutA on at the beginning of the function
// USB_MIDI1_ProcessUsbOut() when data comes to be put in the UART1 out
// buffer.
//
// To enable interrupts set USB_(MIDI descriptor)_(External Mode) = True  
//==============================================================================

//void USB_MIDI1_ProcessUsbOut_EntryCallback(void)
//{
//    BlinkLED();
//
//}


//==============================================================================
// Function Name: USB_MIDI1_ProcessUsbOut_ExitCallback
//==============================================================================
// Summary:  Turn the LED_OutA off at the end of the function  
// USB_MIDI1_ProcessUsbOut() when data is put in the UART1 out-buffer.
//
// To enable interrupts set USB_(MIDI descriptor)_(External Mode) = True
//==============================================================================
/*
void USB_MIDI1_ProcessUsbOut_ExitCallback(void)
{
    //LED_OutA_Write(0);
}
*/

/* [] END OF FILE */

 

Any help would be appreciated. 

 

0 Likes
3 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Greg,

The code looks like my old Piano project. I can look into it on weekend, unless someone helps you before that.

 

I would really appreciate that, thank you.

0 Likes

Greg,

I opened and compiled your project using Creator 4.4 without any issues. I can't check it for Creator 4.2 compatibility, as I don't have it installed. 

     I recommend to close Creator and delete temp files folder, Generated source folder and *.cyfit file.

0 Likes