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);
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?
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>
[/code]
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.
#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);
[/code]
Transfer of a single byte:
[code]
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
[/code]
please use a different name
Best Regards, Thorsten.