Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/16/2015 in all areas

  1. 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 point
×
×
  • Create New...