So I added some encoders to my setup, all was fine until I put the MIOS_ENC_TABLE in and now get this error:
“expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token”
I’m using the app_skeleton.
Can anyone can tell me whats wrong?
Thanks
S
So I added some encoders to my setup, all was fine until I put the MIOS_ENC_TABLE in and now get this error:
“expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token”
I’m using the app_skeleton.
Can anyone can tell me whats wrong?
Thanks
S
I have no idea what exactly you have been doing, so it’s a bit difficult to analyze what went wrong. Maybe you should post the relevant code snippet? Use the “Insert Code Snippet” button from the Post menu!
Like this:
Thanks again.
// $Id: app.c 690 2009-08-04 22:49:33Z tk $
/*
* MIOS32 Application Template
*
* ==========================================================================
*
* Copyright (C) <year> <your name> (<your email address>)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
#include <mios32.h>
#include "app.h"
#include <aout.h>
#include "mios32_enc.h"
#define NUM_ENCODERS 8
MIOS_ENC_TABLE {
// sr pin mode
MIOS_ENC_ENTRY( 6, 0, DETENTED2), //
MIOS_ENC_ENTRY( 6, 2, DETENTED2), //
MIOS_ENC_ENTRY( 6, 4, DETENTED2), //
MIOS_ENC_ENTRY( 6, 6, DETENTED2), //
MIOS_ENC_ENTRY( 7, 0, DETENTED2), //
MIOS_ENC_ENTRY( 7, 2, DETENTED2), //
MIOS_ENC_ENTRY( 7, 4, DETENTED2), //
MIOS_ENC_ENTRY( 7, 6, DETENTED2), //
MIOS_ENC_EOT
};
u8 enc_virtual_pos[NUM_ENCODERS];
/////////////////////////////////////////////////////////////////////////////
// This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
// initialize all LEDs
MIOS32_BOARD_LED_Init(0xffffffff);
}
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
// endless loop
while( 1 ) {
// toggle the state of all LEDs (allows to measure the execution speed with a scope)
MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());
}
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a MIDI package has been received
/////////////////////////////////////////////////////////////////////////////
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
{
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called before the shift register chain is scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServicePrepare(void)
{
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called after the shift register chain has been scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServiceFinish(void)
{
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
}
My button code goes here....
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called when an encoder has been moved
// incrementer is positive when encoder has been turned clockwise, else
// it is negative
/////////////////////////////////////////////////////////////////////////////
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
{
// toggle Status LED on each AIN value change
MIOS32_BOARD_LED_Set(1, ~MIOS32_BOARD_LED_Get());
// increment to virtual position and ensure that the value is in range 0..127
int value = enc_virtual_pos[encoder] + incrementer;
if( value < 0 )
value = 0;
else if( value > 127 )
value = 127;
// only send if value has changed
if( enc_virtual_pos[encoder] != value ) {
// store new value
enc_virtual_pos[encoder] = value;
// send event
MIOS32_MIDI_SendCC(DEFAULT, Chn1, 0x10 + encoder, value);
}
}
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
{
}
You forgot to mention the important detail that you are trying to compile the code for MIOS32…
MIOS_ENC_TABLE isn’t supported anymore, instead encoders have to be installed with the MIOS32_ENC_ConfigSet() function.
(especially README.txt and app.c)
In order to assign the encoders to SR6/SR7 (as in your table), write:
// initialize rotary encoders of the same type (DETENTED2)
int enc;
for(enc=0; enc<NUM_ENCODERS; ++enc) {
u8 pin_sr = enc >> 2; // each DIN SR has 4 encoders connected
pin_sr += 6; // because Sparx connected the first encoders to SR6..SR7
u8 pin_pos = (enc & 0x3) << 1; // Pin position of first ENC channel: either 0, 2, 4 or 6
mios32_enc_config_t enc_config = MIOS32_ENC_ConfigGet(enc);
enc_config.cfg.type = DETENTED2; // see mios32_enc.h for available types
enc_config.cfg.sr = pin_sr;
enc_config.cfg.pos = pin_pos;
enc_config.cfg.speed = NORMAL;
enc_config.cfg.speed_par = 0;
MIOS32_ENC_ConfigSet(enc, enc_config);
}
[/code]
More MIOS32 programming examples can be found under:
[http://www.ucapps.de/mios32\_c.html](http://www.ucapps.de/mios32_c.html)
Don't mix them with MIOS8 examples.
Best Regards, Thorsten.
Thank you, thank you.
Got that going.
No doubt I will be back with more questions…
Thanks again.
I get a similar error, but I’m using MIOS8. Here is the top of my main.c:
/*
* MIOS SDCC Wrapper + ACSIM + Code::Blocks
*
* ==========================================================================
*
* Copyright © <year> <name> (<email>)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
include “main.h”
#ifndef _DEBUG_C
include “cmios.h”
include “pic18f452.h”
#endif
// absolute values are stored in these arrays
unsigned char pot_last_value[64];
unsigned char pot_active_value[64];
MIOS_ENC_TABLE
{
// sr pin mode
MIOS_ENC_ENTRY( 9, 0, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 1
MIOS_ENC_ENTRY( 9, 2, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 2
MIOS_ENC_ENTRY( 9, 4, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 3
MIOS_ENC_ENTRY( 9, 6, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 4
MIOS_ENC_ENTRY( 10, 0, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 5
MIOS_ENC_ENTRY( 10, 2, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 6
MIOS_ENC_ENTRY( 10, 4, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 7
MIOS_ENC_ENTRY( 10, 6, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 8
MIOS_ENC_ENTRY( 11, 0, MIOS_ENC_MODE_NON_DETENTED), // V-Pot 9
MIOS_ENC_EOT
};
I get a syntax error which just refers to the first ‘{’ token when trying to build.
I have altered the Makefile to include -DDONT_INCLUDE_MIOS_ENC_TABLE as well.
Thanks
Has anyone experienced a similar error? I’ve followed the codeblocks setup to the tee and now its falling at the first hurdle, which is somewhat frustrating
It seems that this template is expired (it has been created many years ago)
Could you please try this skeleton application instead?
-> http://www.ucapps.de/mios/sdcc_skeleton_v1_1.zip
The sources have to be compiled with the “make” command, see also: http://www.midibox.org/dokuwiki/doku.php?id=windows_toolchain_quickstart
The usage of perl, “mkmk.pl” etc. is not required anymore.
It seems that nobody maintains the old wiki pages ![]()
(I’m neither a Windows, nor a Codeblocks user)
Best Regards, Thorsten.
Thanks, I’ll give that a go later
Finally managed to compile and upload my code. Buttons, encoders and LEDs seem ok, just some noisy pots letting it down by the looks of things. Have got some exams coming up so will leave it for a few weeks
Thanks for the confirmation that it helped! ![]()
Best Regards, Thorsten.