Jump to content


Photo
- - - - -

AOut driving


  • Please log in to reply
4 replies to this topic

#1 sparx

sparx

    MIDIbox Addict

  • Programmer
  • PipPip
  • 222 posts

Posted 07 November 2011 - 10:17

Have been attempting to get a DOut x 2 working on J19, have read the documentation and tried the examples, but its not behaving how I would expect it to.
What I need it to do is to get a value from an encoder position, which will be 4 bits and put this out to the 595’s. Ultimately it will be two encoders, 4 bits each, making up a byte.
At the moment, the value is shifted left 9 places and is set to count to 255, however after it gets to 64, incorrect values are displayed on the 595 output.

Its being initialised like this:

// initialize AOUT module
  AOUT_Init(0);

  // configure interface
  // see AOUT module documentation for available interfaces and options
  aout_config_t config;
  config = AOUT_ConfigGet();
  config.if_type = AOUT_IF_74HC595;
  config.if_option = 0xffffffff;
  config.num_channels = 8; // INTDAC: only 2 channels supported, 8 channels pre-configured for your own comfort
  config.chn_inverted = 0;
  AOUT_ConfigSet(config);
  AOUT_IF_Init(0);
And sent to the 595’s on J19 like this:

AOUT_PinSet(1,value<<9);
AOUT_Update();

Can anyone see what is going wrong?

Thanks all

Regards

S

#2 Shuriken

Shuriken

    MIDIbox Guru

  • Programmer
  • PipPipPipPip
  • 510 posts
  • LocationAlkmaar, the Netherlands

Posted 10 November 2011 - 09:42

Have been attempting to get a DOut x 2 working on J19, have read the documentation and tried the examples, but its not behaving how I would expect it to.
What I need it to do is to get a value from an encoder position, which will be 4 bits and put this out to the 595’s. Ultimately it will be two encoders, 4 bits each, making up a byte.
At the moment, the value is shifted left 9 places and is set to count to 255, however after it gets to 64, incorrect values are displayed on the 595 output.

Its being initialised like this:

// initialize AOUT module
  AOUT_Init(0);

  // configure interface
  // see AOUT module documentation for available interfaces and options
  aout_config_t config;
  config = AOUT_ConfigGet();
  config.if_type = AOUT_IF_74HC595;
  config.if_option = 0xffffffff;
  config.num_channels = 8; // INTDAC: only 2 channels supported, 8 channels pre-configured for your own comfort
  config.chn_inverted = 0;
  AOUT_ConfigSet(config);
  AOUT_IF_Init(0);
And sent to the 595’s on J19 like this:

AOUT_PinSet(1,value<<9);
AOUT_Update();

Can anyone see what is going wrong?

Thanks all

Regards

S


In the first sentence you say DOUT. But the code is for AOUT. So what is it?

#3 TK.

TK.

    MIDIbox Guru

  • Administrators
  • 12,445 posts
  • LocationGermany

Posted 10 November 2011 - 20:11

The AOUT driver behaves like expected, because it only supports 12/4 and 8/8 bit mode as described here:
//!  <LI>2 (AOUT_IF_74HC595):<BR>
//!      CV: up to 32 cascaded 74HC595 (each MBHP_AOUT_LC module provides 2 74HC595)<BR>
//!      Resolution is selectable with interface_option, each 74HC595 has an own bit
//!      which define:
//!      <UL>
//!        <LI>0: 12/4 bit configuration
//!        <LI>1: 8/8 bit configuration
//!      </UL>
//!      Examples:
//!      <UL>
//!        <LI>0x00000000: all AOUT_LC modules used for 12/4 bit configuration
//!        <LI>0xffffffff: all AOUT_LC modules used for 8/8 bit configuration
//!        <LI>0x00000003: first AOUT_LC used for 8/8 bit configuration, all others for 12/4
//!        <LI>0x0000000c: second AOUT_LC used for 8/8 bit configuration, all others for 12/4
//!      </UL>
//!      Digital: none</LI>

What are you planning to do exactly?

Wouldn't it be easier to output the values with DOUT modules connected to J8/J9?

Best Regards, Thorsten.
Posted Image Buy TK a Beer Disclaimer: buying TK a beer gets you absolutely nothing in return likesuchas firmware enhancements, technical advices and MIDIbox troubleshooting assistance.

#4 sparx

sparx

    MIDIbox Addict

  • Programmer
  • PipPip
  • 222 posts

Posted 10 November 2011 - 21:13

Thanks for the replies.

What I was trying to do was to use J19 for DOuts.

J8/J9 are practically full in the configuration I'm using, so was trying to find another way to get DOUTs.

Regards

S

#5 TK.

TK.

    MIDIbox Guru

  • Administrators
  • 12,445 posts
  • LocationGermany

Posted 10 November 2011 - 23:00

You can use J19 for DOUTs of course - just access it directly with MIOS32_SPI functions like I did in the aout.c driver:
http://svnmios.midib...les/aout/aout.c

Initialisation:
#ifdef MIOS32_BOARD_MBHP_CORE_STM32
    // MBHP_CORE_STM32: pins in open drain mode (to pull-up the outputs to 5V)
    status |= MIOS32_SPI_IO_Init(AOUT_SPI, MIOS32_SPI_PIN_DRIVER_STRONG_OD);
#else
   // MBHP_CORE_LPC17 (and others): pins in push-poll mode (3.3V output voltage)
    status |= MIOS32_SPI_IO_Init(AOUT_SPI, MIOS32_SPI_PIN_DRIVER_STRONG);
#endif

    // init SPI port for fast frequency access
    status |= MIOS32_SPI_TransferModeInit(AOUT_SPI, MIOS32_SPI_MODE_CLK0_PHASE1, MIOS32_SPI_PRESCALER_4);

Transfer of a single byte:
    u8 my_byte 0x42;
    MIOS32_SPI_TransferByte(AOUT_SPI, my_byte);

    // toggle RCLK pin
    MIOS32_SPI_RC_PinSet(AOUT_SPI, AOUT_SPI_RC_PIN, 1); // spi, rc_pin, pin_value
    MIOS32_SPI_RC_PinSet(AOUT_SPI, AOUT_SPI_RC_PIN, 0); // spi, rc_pin, pin_value

For multiple bytes just call MIOS32_SPI_TransferByte multiple times and capture the value by toggling the RCLK pin

AOUT_SPI is set to:
// Which SPI peripheral should be used
// allowed values: 0 (J16), 1 (J8/9) and 2 (J19)
#ifndef AOUT_SPI
#define AOUT_SPI 2
#endif

please use a different name

Best Regards, Thorsten.
Posted Image Buy TK a Beer Disclaimer: buying TK a beer gets you absolutely nothing in return likesuchas firmware enhancements, technical advices and MIDIbox troubleshooting assistance.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users