Jump to content

TK.

Administrators
  • Posts

    15,247
  • Joined

Posts posted by TK.

  1. Search for mios32_midi_chn_t in this file

    (CTRL+F, then enter this keyword into the search mask of your web browser)

     

    Again: this file is included by default (via mios.h), you can just use the enum as shown in my example.

     

    Btw.: you don't need to copy&paste such code into the posting, please reference it with the SVN link: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Finclude%2Fmios32%2Fmios32_midi.h

     

    Best Regards, Thorsten.

  2. I don't know a good reference for such topics, I just observe and decide, and if I'm unsure, I measure ;-)

     

    After a successful build you will find an assembler listing under project_build/project.lss which gives some useful information, e.g. how many assembly instructions are generated by a C construct. Makes sense to check this file from time to time...

     

     

    Should I be concerned about straightforward math?  ...like, should I try not to multiply/divide/add/concatenate/etc. things unless absolutely necessary, or is the impact of straightforward evaluation like that relatively minimal? 

     

    Cortex-M has special instructions for these math operations, therefore no need to be worried about this.

     

     

    How about structures like if or switch statements?

     

    Depends on the implementation and available alternative methods.

     

    E.g. sooner or later I will optimize the large switch statements in seq_cc.c by a lookup table.

    I did something similar in MBCV V2 (-> http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fprocessing%2Fmidibox_cv_v2%2Fsrc%2Fcomponents%2FMbCv.cpp ) with great success.

     

    But it's not worth the effort for switch statements below 30..40 items, and I don't think that you've to consider this in your code domain...

     

    If I see something "which hurts", I will optimize it sooner or later and show you the improved version.

     

    Best Regards, Thorsten.

  3. Cool, thanks for the changes! :smile:

     

    First of all: I gave you access to the (hidden) Programmers Lounge.

    Here are the informations about SVN write access to the repository: 

     

    It makes sense that you upload your changes directly to the repository - I can always switch back to an earlier version if I'm not happy with the changes. ;-)

     

    I also added a new type in seq_robotize.h which simplifies the access to robotizer flags:

    typedef union {
      u8 ALL;
      struct {
        u8 SUSTAIN:1;
        u8 NOFX:1;
        u8 ECHO:1;
        u8 DUPLICATE:1;
      };
    } seq_robotize_flags_t;
    

    Sustain: search for tcc->mode.SUSTAIN, just OR this flag with the robotizer flag: (tcc->mode.SUSTAIN || robotizer_flags.SUSTAIN)

     

    Don't put temporary flags into the CC array, it's better to keep them in the local stack like it's currently done.

     

    From time to time it makes sense to check the performance impact of your code.

    Go to the INFO page (Main menu, GP#16), the Stopwatch will display the consumed time for each SEQ_CORE_Tick()

    The maximum value will be captured and can be cleared by pressing GP9 button in this page.

     

    Currently the function consumes +30 uS on a STM32F1 if a single track is playing.

     

    It could be improved.

    E.g. I noticed that you reverted an important change that I made: you are writing for example:

      if( ( (s16)SEQ_RANDOM_Gen_Range(0, 31 * 31) <= tcc->robotize_oct_probability * roboprob ) && robooct ) { // Octave Event
    

    but it's better to write:

      if( robooct && ( (s16)SEQ_RANDOM_Gen_Range(0, 31 * 31) <= tcc->robotize_oct_probability * roboprob ) ) { // Octave Event 

    so that SEQ_RANDOM_Gen_Range() won't be called if robooct isn't activated

     

    Same for robonote, robovel, robolen

     

    The copy of tcc-> variables into local variables isn't really necessary:

      roboprob = tcc->robotize_probability;
      robovel = tcc->robotize_vel;
      robolen = tcc->robotize_len;
      robonote = tcc->robotize_note;
      robooct = tcc->robotize_oct;
      roboskip = tcc->robotize_skip_probability;
      robosustain = tcc->robotize_sustain_probability;
      robonofx = tcc->robotize_nofx_probability;
      roboecho = tcc->robotize_echo_probability;
      roboduplicate = tcc->robotize_duplicate_probability;

    because the impact of indirect addressing isn't so high compared to other things (such as function calls)

    I would remove this - it makes the code more difficult to maintain.

     

    Best Regards, Thorsten.

  4. From the documentation:

     

    The Error Codes (0E)
    ~~~~~~~~~~~~~~~~~~~~
    
       Structure:
          F0 00 00 7E 40 <device-id> 0E <error code> <additional information> F7
    
          <device-id>:  the MIOS device ID from 00 to 7F
          <error code>: see below
          <additional information>: for internal use, ignore it
    
    
       Error Code | Description
       -----------+---------------------------------------------------------------
        0x01      | Less bytes than expected have been received
        0x02      | More bytes than expected have been received
        0x03      | Checksum mismatch
        0x04      | Write failed (verify error or invalid address)
        0x05      | Write access failed (invalid address range) - 
                  | used by 1st level bsl
        0x06      | MIDI Time Out
        0x07      | Wrong Debug Command
        0x08      | 2nd level bsl: Read/Write command tried to access an invalid 
                  | address range
        0x09      | 2nd level bsl: Read/Write address not correctly aligned
        0x0a      | BankStick not available
        0x0b      | MIDI IN Overrun (CPU load too high)
        0x0c      | MIDI IN Frame Error (Bad signal/Optocoupler)
    

    You got 0xc -> bad signal or optocoupler.

     

    If the resistor values are ok now, try another 6N138

     

    Best Regards, Thorsten.

  5. Just enable Boot Hold mode and upload the fixed application under save conditions with MIOS Studio (under Linux or whatever OS you like)

     

    See also in this picture. However, the Primer contains an integrated debug interface which makes it easy to recover the MIOS32 installation w/o this measure.

  6. MBHP_CORE_LPC17: stuff jumper J27 (BL Hold) to select the bootloader hold mode, thereafter power-cycle the core.
  7. MBHP_CORE_STM32F4 and STM32F4DISCOVERY: press and hold the blue "User" button, trigger the black "Reset" button shortly. This will restart the core and enforce bootloader mode as long as the blue "User" button is pressed.
  8. Best Regards, Thorsten.

×
×
  • Create New...