Hi all, My project involves controlling a quad 16-bit dac through spi from a single rotary encoder. I've spent quite a few hours trying to figure this out but am getting nowhere.
I've got my dac(TI 8555) working just fine using the SPI library, and for the most part have my encoder(ENC1J-D28-L00128L-ND) working fine by itself.
The problem I'm having is that when I combine the code for the dac and the encoder my arduino appears to be freezing after ~4s regardless of whether or not I turn the encoder. I've tried polling the encoder but due to my lack of foresight I purchased an encoder that has too many steps/rev and at moderate-high speeds I begin to lose steps.
I've read that delay() does not work inside of interrupts. This could be a possible hangup if I assume the SPI library must use some kind of delay in order for setClockDivider() to function.
Another thought I had was that interrupts are being temporarily disabled and qued during the function associated with the interrupt. I know that SPI uses some form of interrupt and this also could be causing an issue.
A few other constraints that need to be kept in mind:
I will be adding in a 4x40 char LCD. I've also got this working fine by itself but am worried the time needed to run the SPI code and update the LCD will limit my options using either interrupts or polling of the encoder.
I don't need the dac to be updated for every increment/decrement of the encoder. I do, however, need the encoder position to be updated fairly accurately.
I don't mind doing the leg work on this but a little bit of insight or a kick in the right direction would greatly appreciated. Thanks!