sparx Posted November 7, 2011 Report Share Posted November 7, 2011 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 Quote Link to comment Share on other sites More sharing options...
Shuriken Posted November 10, 2011 Report Share Posted November 10, 2011 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? Quote Link to comment Share on other sites More sharing options...
TK. Posted November 10, 2011 Report Share Posted November 10, 2011 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. Quote Link to comment Share on other sites More sharing options...
sparx Posted November 10, 2011 Author Report Share Posted November 10, 2011 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 Quote Link to comment Share on other sites More sharing options...
TK. Posted November 10, 2011 Report Share Posted November 10, 2011 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.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fmodules%2Faout%2Faout.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); [/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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.