mwpost Posted December 26, 2014 Report Share Posted December 26, 2014 Hi there, need some hints for my project (midification of a tube preamp): I try to get output of an PGA2311, but no success so far. The PGA2311 is connected to the Core via J19, RC1 is used. Extra +/-5.0 Volts for the analogue section is provided via extra power supply. Here is my code: For Initialization: MIOS32_MIDI_SendDebugMessage("SPI Init: %03u\n", MIOS32_SPI_IO_Init(2, MIOS32_SPI_PIN_DRIVER_STRONG_OD)); For change of Gain: MIOS32_MIDI_SendDebugMessage("SPI_Transfer: %04u Return: %04u\n", senden, MIOS32_SPI_TransferByte(2, 0xff)); Initialization returns "000" and Change of Gain return "255" in the Debug Window of MIOS Studio which is well expected from my side. Maybe someone can help me? Kindly :santa: :santa: mwpost Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 3, 2015 Author Report Share Posted January 3, 2015 I cannot believe that nobody is able to help? :sad: Quote Link to comment Share on other sites More sharing options...
TK. Posted January 3, 2015 Report Share Posted January 3, 2015 I missed your message... Are you using a MBHP_CORE_STM32 or MBHP_CORE_LPC17/MBHP_CORE_STM32F4 module? For MBHP_CORE_STM32 the MIOS32_SPI_PIN_DRIVER_STRONG_OD mode would be correct. But MBHP_CORE_STM32F4/LPC17 require MIOS32_SPI_PIN_DRIVER_STRONG_PP Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 3, 2015 Author Report Share Posted January 3, 2015 Thanks Thorsten for your reply, I am using the STM32F4 and will try the settings above. Maybe you also have the possibility to provide the MBMixer Software in C instead of ASM? Or an alternative code snippet in C? I have no idea about ASM ... :pirate: :question: :question: :nuke: Kindly, mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 3, 2015 Report Share Posted January 3, 2015 The author of the MIOS8 based MBMixer software wrote some parts in assembler, I've no alternative sources available. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 4, 2015 Author Report Share Posted January 4, 2015 I missed your message... Are you using a MBHP_CORE_STM32 or MBHP_CORE_LPC17/MBHP_CORE_STM32F4 module? For MBHP_CORE_STM32 the MIOS32_SPI_PIN_DRIVER_STRONG_OD mode would be correct. But MBHP_CORE_STM32F4/LPC17 require MIOS32_SPI_PIN_DRIVER_STRONG_PP Best Regards, Thorsten. MIOS32_SPI_PIN_DRIVER_STRONG_PP is no available option. See declaration ... ///////////////////////////////////////////////////////////////////////////// //! (Re-)initializes SPI IO Pins //! By default, all output pins are configured with weak open drain drivers for 2 MHz //! \param[in] spi SPI number (0, 1 or 2) //! \param[in] spi_pin_driver configures the driver strength: //! <UL> //! <LI>MIOS32_SPI_PIN_DRIVER_STRONG: configures outputs for up to 50 MHz //! <LI>MIOS32_SPI_PIN_DRIVER_STRONG_OD: configures outputs as open drain //! for up to 50 MHz (allows voltage shifting via pull-resistors) //! <LI>MIOS32_SPI_PIN_DRIVER_WEAK: configures outputs for up to 2 MHz (better EMC) //! <LI>MIOS32_SPI_PIN_DRIVER_WEAK_OD: configures outputs as open drain for //! up to 2 MHz (allows voltage shifting via pull-resistors) //! </UL> //! \return 0 if no error //! \return -1 if disabled SPI port selected //! \return -2 if unsupported SPI port selected //! \return -3 if unsupported pin driver mode ///////////////////////////////////////////////////////////////////////////// So I guess you meant to use MIOS32_SPI_PIN_DRIVER_STRONG in my case (I use STM32F4 dicovery)... Quote Link to comment Share on other sites More sharing options...
TK. Posted January 4, 2015 Report Share Posted January 4, 2015 Yes, correct. The IO pins have to be configured for push-pull mode (and not open-drain mode). Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 4, 2015 Author Report Share Posted January 4, 2015 Hmm - no success so far. Maybe a post of my complete code helps in finding the error: ///////////////////////////////////////////////////////////////////////////// // Include files ///////////////////////////////////////////////////////////////////////////// #include <mios32.h> #include "app.h" ///////////////////////////////////////////////////////////////////////////// // Local definitions ///////////////////////////////////////////////////////////////////////////// #define NUM_ENCODERS 64 ///////////////////////////////////////////////////////////////////////////// // Local variables ///////////////////////////////////////////////////////////////////////////// u8 Sendbyte; 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); // initialize pin0 & pin1 of J5A as output with internal Pull-Up MIOS32_BOARD_J5_PinInit(0, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinInit(1, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinInit(2, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinInit(3, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); // initialize rotary encoders of the same type (DETENTED2) int enc=0; //for(enc=0; enc<=NUM_ENCODERS; ++enc) { //u8 pin_sr = enc >> 2; // each DIN SR has 4 encoders connected //u8 pin_pos = (enc & 0x3) << 1; // Pin position of first ENC channel: either 0, 2, 4 or 6 u8 pin_sr = 1; u8 pin_pos = 0; 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 = FAST; enc_config.cfg.speed_par = 3; MIOS32_ENC_ConfigSet(enc, enc_config); // reset virtual positions enc_virtual_pos[enc] = 0; //} MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_IO_Init(2, MIOS32_SPI_PIN_DRIVER_STRONG): %03u\n", MIOS32_SPI_IO_Init(2, MIOS32_SPI_PIN_DRIVER_STRONG)); } ///////////////////////////////////////////////////////////////////////////// // This task is running endless in background ///////////////////////////////////////////////////////////////////////////// void APP_Background(void) { // MIOS32_LCD_Initialize MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); // X, Y MIOS32_LCD_PrintString("PreAmp Volume"); MIOS32_LCD_CursorSet(0, 1); // X, Y MIOS32_LCD_PrintString(" Off 0000"); while (1) { } } ///////////////////////////////////////////////////////////////////////////// // 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) { // 1) LED an, wenn Gain (CC=52) <> 0 auf Midi-Kanal 3 if( midi_package.chn == 2 && midi_package.type == CC && midi_package.cc_number == 52 && midi_package.value != 0) { //Kanalschalter-LED Frontseite einschalten MIOS32_BOARD_J5_PinSet(0, 1); //Relais durchschalten auf Pin1 MIOS32_BOARD_J5_PinSet(1, 1); MIOS32_LCD_CursorSet(1, 1); MIOS32_LCD_PrintString("On "); } // 2) LED aus, wenn Gain (CC=52) = 0 auf Midi-Kanal 3 else if( midi_package.chn == 2 && midi_package.type == CC && midi_package.cc_number == 52 && midi_package.value == 0) { //Kanalschalter-LED Frontseite ausschalten MIOS32_BOARD_J5_PinSet(0, 0); //Relais unterbrechen auf Pin1 MIOS32_BOARD_J5_PinSet(1, 0); MIOS32_LCD_CursorSet(1, 1); MIOS32_LCD_PrintString("Off"); } // forward USB0->UART0 and UART0->USB0 switch ( port ) { case USB0: MIOS32_MIDI_SendPackage(UART0, midi_package); break; case UART0: MIOS32_MIDI_SendPackage(USB0, midi_package); break; } } ///////////////////////////////////////////////////////////////////////////// // 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) { } ///////////////////////////////////////////////////////////////////////////// // 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 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(0x0001, ~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; enc_virtual_pos[encoder] = value; // 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(UART0, Chn3, 53, value); MIOS32_MIDI_SendCC(USB0, Chn3, 53, value); short Sendbyte = value*2; MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_RC_PinSet to 0: %04u", MIOS32_SPI_RC_PinSet (2,1,0)); MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_TransferByte R %04u: %04u", Sendbyte, MIOS32_SPI_TransferByte(2, Sendbyte)); MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_TransferByte L: %04u: %04u", Sendbyte, MIOS32_SPI_TransferByte(2, Sendbyte)); MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_RC_PinSet to 1: %04u", MIOS32_SPI_RC_PinSet (2,1,1)); MIOS32_LCD_CursorSet(10, 1); MIOS32_LCD_PrintFormattedString("%04u", Sendbyte); } ///////////////////////////////////////////////////////////////////////////// // This hook is called when a pot has been moved ///////////////////////////////////////////////////////////////////////////// void APP_AIN_NotifyChange(u32 pin, u32 pin_value) { } These are the global compiler settings: Processor: STM32F407VG Family: STM32F4xx Board: MBHP_CORE_STM32F4 LCD: universal The encoder as well as the update on the LCD with every turn is working quite fine. But the PGA does not seem to transmit any audio... Thanks for patience, mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 4, 2015 Report Share Posted January 4, 2015 I noticed two errors: 1) beside the IO pins, you also have to initialize the SPI protocol. Here the appr. code for APP_Init(): // initialize SPI IO pins and protocol MIOS32_SPI_IO_Init(2, MIOS32_SPI_PIN_DRIVER_STRONG); MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE0, MIOS32_SPI_PRESCALER_16); // ca. 5 MBit 2) MIOS32_SPI_RC_PinSet() sets the RC2 pin instead of RC1 Use: MIOS32_SPI_RC_PinSet(2, 0, 0); to set J19:RC1=0, and MIOS32_SPI_RC_PinSet(2, 0, 1) to set J19:RC1=1 After the modifications the transmitted values look ok on the scope. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 10, 2015 Author Report Share Posted January 10, 2015 Hi Thorsten, thanks for your support. At least I now get a response from the PGA that make sense. The read byte from the MIOS_SPI_TransferByte function now equals the settings (for most of the cases). Before I always received 255 as a response to this function nevertheless which byte I sent to the PGA2311. I guess this is a positive sign and the digital section of the IC is working. But I still get no change in the Ouput of the chip. I also try a second PGA2311 to exclude that the chip is defective. So maybe I did wrong wiring. Here is my schematic. Don't get confused by the audio connectors, my software only has Switched Stereo Plugs available ;-) Any idea? Kindly, mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 10, 2015 Report Share Posted January 10, 2015 Are the MUTE# and ZCEN inputs really unconnected? Both should be connected to VD+ Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 11, 2015 Author Report Share Posted January 11, 2015 Finally! I now get output - Thanks so far!! But maybe you can help further: I now make 2 observations: 1) The PGA2311 is not having increasing/decreasing steps when I turn my encoder, even if the variable "value" increases/decreases 1 by 1... :sick: Instead, I get the PGA2311 obviously hopping between values out of the row, it seems to be a random order. Do I need to bitshift the value to follow the requirement of MSB first for the PGA2311? How could that be implemented in my code above? 2) The PGA2311 is not reacting very reliable to the function MIOS32_SPI_TransferByte. I need to execute the function twice to get a reasonable return value (e.g. 0x7F). :rofl: 3) The readbyte (as a return of the function MIOS32_SPI_TransferByte) is not corresponding correctly to the value that has been set. Furthermore it returns the value that has been set in the last call of the function. Thats confusing me. Any hints? :question: :question: mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 11, 2015 Report Share Posted January 11, 2015 1) The PGA2311 is not having increasing/decreasing steps when I turn my encoder, even if the variable "value" increases/decreases 1 by 1... :sick: Instead, I get the PGA2311 obviously hopping between values out of the row, it seems to be a random order. I guess that the chips expects the MSB first, which means that the byte has to be mirrored. Please try: MIOS32_SPI_TransferByte(2, mios32_dout_reverse_tab[Sendbyte]) this should do the trick 2) The PGA2311 is not reacting very reliable to the function MIOS32_SPI_TransferByte. I need to execute the function twice to get a reasonable return value (e.g. 0x7F). :rofl: 3) The readbyte (as a return of the function MIOS32_SPI_TransferByte) is not corresponding correctly to the value that has been set. Furthermore it returns the value that has been set in the last call of the function. Thats confusing me. Any hints? :question: :question: that's the normal shift register behaviour, it can't shift out the value which is currently shifted in. It will be shifted out with the next transaction. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 14, 2015 Author Report Share Posted January 14, 2015 Unfortunately, MIOS32_SPI_TransferByte(2, mios32_dout_reverse_tab[Sendbyte]) did not function. Any other hints? Am I wrong or doesn't the function "MIOS32_SPI_TransferByte" expects a u8 value for the second argument? On the other hand, the PGA2311 is awaiting a transfer of a 2byte (=16bits) value on the other hand. So just calling the function twice may not be the appropriate solution, is it? mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 14, 2015 Report Share Posted January 14, 2015 No other idea; try to find out the logic behind the observed behaviour. In order to transfer 16 bits (= 2 * u8) just call the MIOS32_SPI_TransferByte function two times between the RC1 activation/deactivation. You are already doing this in the code that you've showed in the first posting. Btw.: the PGA2311 specifies 8 bits per volume level, but your value only ranges between 0..127 (=7 bit) This is not the reason for the behaviour, but it makes sense to change the range from 0..255 anyhow Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 14, 2015 Author Report Share Posted January 14, 2015 Hi Thorsten, you are correct with the 7-bit. I already changed this, but thanks for your "heads up". :thumbsup: The rest of your message is frustrating me a little bit. :sad: I've been trying to find solutions in this and other forums like DIYAudio.com, but no solution. I would really appreciate to get a code snippet in C that has been checked to be sure someone has made it run bevore with MIOS32 and the STM32F4. I would not need any extra features by now (just the core and the PGA) and would be more than happy to know where the failure is. After your check of the hardware with the scope I would assume that the problem is more related to the software. The sample in Midibox mixer is not of big help as I have absolute no knowledge in ASM. :excl: So maybe someone else can step in and assist? Kindly, mwpost Quote Link to comment Share on other sites More sharing options...
pilo Posted January 16, 2015 Report Share Posted January 16, 2015 Hi mwpost! I wrote PGA driver code for pic18f years ago (looking at the source code, it should make 10 years...), which was later improved by Lyle. I remember having fun writing the display part in asm :smile: Anyway, I'll try to make it work with MIOS32. I think you're very close to have it working, actually I don't see any problem with your code (if you does the modification correctly). According to your schematic only the left part of the PGA is tested, and that's the 2nd byte send to the PGA : void APP_ENC_NotifyChange(u32 encoder, s32 incrementer) { // toggle Status LED on each AIN value change MIOS32_BOARD_LED_Set(0x0001, ~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; // clamp the value if( value < 0 ) value = 0; else if( value > 255 ) value = 255; // store enc_virtual_pos[encoder] = value; MIOS32_MIDI_SendCC(UART0, Chn3, 53, value); MIOS32_MIDI_SendCC(USB0, Chn3, 53, value); u8 Sendbyte = mios32_dout_reverse_tab[value]; // MSB first MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_RC_PinSet to 0: %04u", MIOS32_SPI_RC_PinSet (2,1,0)); MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_TransferByte R %04u: %04u", Sendbyte, MIOS32_SPI_TransferByte(2, Sendbyte)); // right channel gain MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_TransferByte L: %04u: %04u", Sendbyte, MIOS32_SPI_TransferByte(2, Sendbyte)); // left channel gain MIOS32_MIDI_SendDebugMessage("MIOS32_SPI_RC_PinSet to 1: %04u", MIOS32_SPI_RC_PinSet (2,1,1)); MIOS32_LCD_CursorSet(10, 1); MIOS32_LCD_PrintFormattedString("%04u", Sendbyte); } If you daisy chained PGA (or use PGA4311) you should have as many MIOS32_SPI_TransferByte as channels (so you need 2 for one PGA2311, 4 for 2 chained PGA2311, 4 for one PGA4311, 6 for one PGA4311 and one PGA2311, etc). And I wouldn't expect any value returned by MIOS32_SPI_TransferByte? 1 Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 16, 2015 Author Report Share Posted January 16, 2015 (edited) Hi Pilo, Thanks for your confirmation of the code which should be clear now. (Except your little mistake with the PinSet-Function we already discussed ealier (--> it neerds to be MIOS32_SPI_PinSet (2,0,0) and MIOS32_SPI_PinSet (2,0,1) because I have a single PGA2311 connected to RC1 on J19. It is also clear that I need to modify the second byte to change Vol Level for the left channel, which is connected to a mono audio source. What did I do the last 10 years? I would have better spent them on electronics and PIC programming instead of other useless hobbies :hyper: I still think my problems have to do with the STM32F407 discovery. Did you (or Thorsten?) ever try to connect one of the PGA chips to the J19 of a core PCB of a STM32F4?? I mean instead of connecting them to a PIC. If so, you must have had the same problems...? :pirate: So I guess it has something to do with the signal sent by the core through the 74HCT541, no? Again a discription of what I observe: I have over most of the value changes through the encoder no change in the throughput of the PGA. In a sudden the IC seems to understand one Byte transfer and it transmits very loud. This level remains even if I keep on turning the encoder. In a sudden - while I keep on changing values slowly - volume drecreases by different, often very different steps. :poke: The debug messages and the MIDI traffic scanned with MIOS_Studio help me to recognize the change in values. I also get return values as expected after the explanation of Thorsten (not the currenct value is returned but the value that has been replaced by the current value). :shifty: I have another brand new PGA2311 which shows the same beaviour so I would exclude hardware failure of the ICs. Kindly mwpost Edited January 16, 2015 by mwpost Quote Link to comment Share on other sites More sharing options...
pilo Posted January 19, 2015 Report Share Posted January 19, 2015 (edited) Hi mwpost! Unfortunately I didn't had the time this week end to test my old pga pcb with MIOS32 (I have an LPC17 board, not STM32F4, but it shouldn't be a big difference for this). What you could do, is to try to set the gain without the encoder first (comment or remove the code setting the gain in the encoder callback). just add this function in your c file : void SetPGAGain(u8 leftGain, u8 rightGain) { MIOS32_SPI_RC_PinSet (2,0,0); MIOS32_SPI_TransferByte(2, mios32_dout_reverse_tab[rightGain]); // right MIOS32_SPI_TransferByte(2, mios32_dout_reverse_tab[leftGain]); // left MIOS32_SPI_RC_PinSet (2,0,1); } and for example in APP_Background void APP_Background(void) { SetPGAGain(0, 0); while (1) { } } When you start the application, you should hear no sound at all (0 is the special value for MUTE). Then try for example SetPGAGain(32, 32); etc and then with other values, and see how it behave. It might help to understand what is going on by just changing the value once. What did I do the last 10 years? I would have better spent them on electronics and PIC programming instead of other useless hobbies There's no "useless hobby" :smile: I was very excited by the PGA at that time, I ordered some, made a quick board, wrote the code for MIOS... and when it worked, I though "Cool, I need to put it in a very cool project!", and I haven't touch it since... (like so many other "project" I started) Edited January 19, 2015 by pilo 1 Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 19, 2015 Author Report Share Posted January 19, 2015 Hi Pilo, I did setup a new project in eclipse modified the imported template "skeleton" with your proposal. I deleted the APP_Background and pasted your code snippet. Additionally, I also did modify the app.h and included the declaration of the SetPGAGain routine to avoid warnings from the compiler "implizit use of ...". What should I say? No problems with compiling or flash of the Core. But during startup I don't have the volume muted :wacko: at all, I still hear audio coming through very clearly. When I call the SetPGAGain as described in the command line in MIOS Studio I receive "command handler not implemented by the application". Coming to the hobbies: Well, maybe my posts reminded you of starting a new project you wanted to start a long time ago. I came to MIOS and started to learn basic electronics with the objective to have a midified tube preamplifier for my rock organ with the ability to be remote controlled via MIDI. Now I know designing power supplies, rectifiers and maybe soon I will know how this PGA works with my Midibox :rofl: Kindly mwpost Quote Link to comment Share on other sites More sharing options...
pilo Posted January 20, 2015 Report Share Posted January 20, 2015 Hi! Do you setup the SPI intervace in APP_init() ? (I think yes, but it's always good to check everything ;) // initialize SPI IO pins and protocol MIOS32_SPI_IO_Init(2, MIOS32_SPI_PIN_DRIVER_STRONG); MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE0, MIOS32_SPI_PRESCALER_16); // ca. 5 MBit I don't understand why it doesn't work (and unfortunately I don't have my old PGA pcb here with me). I think the command is not working because there's no command handling callback ;) (you can setup one, but you have to parse it etc). I had the idea few month ago to make a preamp with the PGA, but it was a few month ago and I haven't done anything yet... :) Quote Link to comment Share on other sites More sharing options...
TK. Posted January 20, 2015 Report Share Posted January 20, 2015 The MIOS32_SPI_TransferBlock callback isn't required for this use case, it's typically used if the app want's to send a higher amount of bytes (e.g. 64 bytes and more) and shouldn't wait until the bytes have been transmitted, but should execute the callback function instead to notify, that a new block could be sent. However, while you post this: it could make sense to try out different speeds and transfer modes. Try out following configurations: MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE0, MIOS32_SPI_PRESCALER_16); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE1, MIOS32_SPI_PRESCALER_16); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK1_PHASE0, MIOS32_SPI_PRESCALER_16); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK1_PHASE1, MIOS32_SPI_PRESCALER_16); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE0, MIOS32_SPI_PRESCALER_32); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK1_PHASE0, MIOS32_SPI_PRESCALER_32); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE1, MIOS32_SPI_PRESCALER_32); or MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK1_PHASE1, MIOS32_SPI_PRESCALER_32); Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 20, 2015 Author Report Share Posted January 20, 2015 Hi Thorsten, hi Pilo, some further observations (Pilo, I intiated the SPI Port in App_Init!): After reboot (power down & power up) I sometimes have immediatly after switchin power on very good transmission, sometimes nothong. That seems to be alredy before the application boots (LCD message from mios32_config.h occurs a few instances later. I power the PGA as follows: VA- from an external PSU, VA+ and VD+ is directly taken from J19. The Core itself is also powered by the external PSU. Is there a remarkable delay between the Power on of Core and PGA and the Power provided indirectly at J19?. Thorsten, the initiation of the TransferMode doesn't seem to be the problem. Only if set to ... MIOS32_SPI_TransferModeInit(2, MIOS32_SPI_MODE_CLK0_PHASE0, MIOS32_SPI_PRESCALER_16); ... I get response as we found out earlier in this topic. With the other settings the returnbyte didn't not change while using the code I had before. Kindly, mwpost Quote Link to comment Share on other sites More sharing options...
TK. Posted January 20, 2015 Report Share Posted January 20, 2015 So, with MIOS32_SPI_PRESCALER_32 (slower transfer speed) it doesn't work anymore? Please check the resulting behaviour of the chip, not the received value. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
mwpost Posted January 21, 2015 Author Report Share Posted January 21, 2015 <blockquote class='ipsBlockquote'data-author="TK." data-cid="168464" data-time="1421791845"><p> So, with MIOS32_SPI_PRESCALER_32 (slower transfer speed) it doesn't work anymore?<br /> <br /> Please check the resulting behaviour of the chip, not the received value.<br /> <br /> Best Regards, Thorsten.</p></blockquote> 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.