Help needed ! Is there some conflict between HW SPI and ADC sampling on Teensy 3.2 ?

Status
Not open for further replies.

xtof

Active member
[SOLVED] Is there some conflict between HW SPI and ADC sampling on Teensy 3.2 ?

Hi there,

I'm facing an issue on my Teensy dev that I don't understand. Here the concept (which actually works on Arduino MEGA) : I have a Teensy 3.2 board which is managinga GFX display (SSD1322) and a L6470 steeper motor driver both in HW SPI. Both are working fine together. I can define (in code only at this time with some vars) a starting point and a target point to make the motor running from Start to End, and this works without any issues.
To define the start and end points I had developped on MEGA a simple code which samples an analog input, reads the value of a joystick, and depending on its position I'm running the stepper Forward or Backward at a speed corresponding to a remap scale between the null point of the joystick and the maximum.
This is working on MEGA, perfectly, but when I'm using the "same" code on Teensy the steeper starts to run to the maximum, and never stops when the joystick is released. The behavior is really strange.
If I'm desactivating the MOTOR.run() commands, and if I only trace the values readed on the ADC input, they are quite good, varying on 11bit in the range between 0 to 2047 as it should.

I tried to deactivate the SPI display, no changes.
I tried to deactivate the Serial() traces, no changes.
I tried do sample ADC with IntervalTimer, or having a direct analogRead inside the loop(), no changes.

The Analog input used for the joystick is A5 (PIN 19). The joystick circuit is grounded on AGND. The AREF pin is used with a LM4040 circuit which deliver a 2.048V Analog ref at +/- 0.1%. And after some measures and Serial() traces, this part of the circuit is working fine.

So I'm wondering if there is a conflict between reading the ADC every 5 ms with IntervalTimer, or having a analogRead input in the loop (I tried the both - getting the same results) for the joystick and transmit it to the driver board on the fly through SPI with MOTOR.run(FWD, speed) ? Or can it be a conflict on Interrupts ?

Of course I can post the code, but I do admit, that I don't understand why only this part of the code is not working on Teensy 3.2, and the same part is working on MEGA.

Any idea of what can be wrong or not working ? Any help will be really appreciated !
Thanks a lot.
 
Last edited:
Issue on a wire soldering that creates wrong SPI communications between Teensy and L6470 board... Not the first, not the last...

Thanks !
 
Status
Not open for further replies.
Back
Top