Jump to content

Recommended Posts

Posted

Dear Thorsten

Since I first sent this message I realise that I dont need pointers for a character array.  I realise that I only need single quotation marks and dont need the *.  However it should still work. 

Here is the modified code.  I still get the same errors during compilation!

void AIN_NotifyChange(unsigned char pot, unsigned int pin_value) __wparam
{
	//Send Midi Control to Sound Module	 eg B1 08 XX, B0 0B YY etc
    
	unsigned char  status[8] = {'B1', 'B1', 'B1', 'B0', 'B0', 'B0', 'B2', 'B1'};
	unsigned char  byte[8] = {'0x08', '0x0B', '0x09', '0x0B', '0x07', '0x08', '0x0B', '0x01'};




	if( pot >= 0 && pot <=7 ){

	MIOS_MIDI_TxBufferPut(status);
	MIOS_MIDI_TxBufferPut(byte);
	MIOS_MIDI_TxBufferPut(pin_value);}
}
Orig Message I have managed to program on Core 2 the two keyboards complete with:- A)  one Unmuxed  Analog channel generating B1 07 XX B) 2 X 61 keynotes with upper keyboard wired backwards to minimise DIN - DIN cabling C) Coupling of the two keyboards (Double Note On/Off Messages. Thanks very much for your input. 8 Unmuxed Analog Inputs I am attempting to write the code for Core 1 Analog inputs, these are balance controls and Tremelo speed pots.  There are 8 pots.  I have proved that the system will generate Midi Control Changes but  not in the required manner. As you will see below I am attempting to construct a character array pointer with two variables (status) and (byte).  These correspond to the 1st and 2nd bytes of the midi message.  The compilation does not work, I get character incompatibilty problems. (see below).  I am showing the two sections concerned with AIN inputs.
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  // initialize the shift registers
  	MIOS_SRIO_NumberSet(16); // shiftregisters
  	MIOS_SRIO_UpdateFrqSet(1); // mS
  
	MIOS_AIN_NumberSet (8); // number of pots
	MIOS_AIN_UnMuxed ;

	//define deadband, use 7
	MIOS_AIN_DeadbandSet (7);

}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pot, unsigned int pin_value) __wparam
{
	//Send Midi Control to Sound Module	 eg B1 08 XX, B0 0B YY etc
    
	unsigned char * status[8] = {"B1", "B1", "B1", "B0", "B0", "B0", "B2", "B1"};
	unsigned char * byte[8] = {"0x08", "0x0B", "0x09", "0x0B", "0x07", "0x08", "0x0B", "0x01"};




	if( pot >= 0 && pot <=7 ){

	MIOS_MIDI_TxBufferPut(status);
	MIOS_MIDI_TxBufferPut(byte);
	MIOS_MIDI_TxBufferPut(pin_value);}
}

[u]Compiler text[/u]

C:\C_Stops>make
Makefile generated.
Makefile.bat generated.
Directory already exists
Assembling MIOS SDCC wrapper
==========================================================================
Compiling pic18f452.c
Processor: 18F452
==========================================================================
Compiling main.c
Processor: 18F452
main.c:238: error 78: incompatible types
from type 'unsigned-char generic*  [8] '
to type 'unsigned-char'
main.c:239: error 78: incompatible types
from type 'unsigned-char generic*  [8] '
to type 'unsigned-char'
-:0: error 103: code not generated for 'AIN_NotifyChange' due to previous errors

ERROR!

Please note that I am trying the' Hex' 0xB1 and 'straight' B1 data.  Both give the same error.

Please help.

Best Regards Robin

Posted

Hi Robin,

there are two things, which lead to the error.

One thing is, that you are trying to put illegal characters into the table. Characters are quoted with a ', and just single ASCII bytes, and hex codes - typical usecase for a character: MIOS_LCD_PrintChar('A');

Another thing is, that the array is not accessed correctly. Since you want to select a single element, you have to write status[pot] and byte[pot]

In addition, it isn't a good idea to create a new array with constant definitions each time when AIN_NotifyChange is called. It's better to put such static arrays outside the function, and to declare them as "const"

This leads to the effect, that the compiler will put a table into program flash - in a similar way you know from midio_presets.inc

So, here a code snippet which should work:


/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
const unsigned char midi_status[8] = {0xB1, 0xB1, 0xB1, 0xB0, 0xB0, 0xB0, 0xB2, 0xB1};
const unsigned char midi_byte[8] = {0x08, 0x0B, 0x09, 0x0B, 0x07, 0x08, 0x0B, 0x01};

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
  //Send Midi Control to Sound Module  eg B1 08 XX, B0 0B YY etc
  if( pin >= 0 && pin <=7 ){
    MIOS_MIDI_TxBufferPut(midi_status[pin]);
    MIOS_MIDI_TxBufferPut(midi_byte[pin]);
    MIOS_MIDI_TxBufferPut(pin_value);
  }
}
[/code]

Best Regards, Thorsten.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...