Jump to content
  • 0

PMODALS Teensy 3.1 connection


JGRMSL

Question

I am trying to work the PMODALS off of a Teensy 3.1. I was wondering if any one has gotten this connected and working?

If so could you reply with your .h file.  The DSPI is not compatible with the Teensy and converting this to arduino SPI does not seem to be working.

Thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hi JGRMSL,

For a long time at Digilent we did not work with other microcontrollers besides our own; from my understanding this will be changing in the future, but nevertheless we do not have an .ino file for the PmodALS.

It looks like the "DPSI" that the Teensy uses is a DMA SPI, so I would think that rather than converting it to arduino SPI, it would be easier to just start with the arduino SPI library since in terms of what the user sees, the two SPI types should be very similar in output. The biggest things that you need to be aware of are that the PmodALS needs to receive a clock frequency between 1 MHz and 4 MHz and sends out 4 leading zeroes, then the 8 bits of data (MSB first), and then 4 trailing zeros; all of these are limitations of the hardware component present on the PmodALS. 

I have given you a "pseudo C" example below in the arduino/MPIDE style:

#include <SPI.h>

int firstByte;
int secondByte;

void setup(){

     SPI.begin();
     SPI.setMode(MODE0);
     SPI.setClockDivider(); //set the appropriate clock divider setting to get the clock between 1MHz and 4MHz
     //See http://www.arduino.cc/en/Reference/SPISetClockDivider for more details
     pinMode(SlavePin, OUTPUT);

}

void loop(){

     collectData();
     delay(1000);

}

void collectData(){

     firstByte = SPI.transfer(0x00);
     firstByte = firstByte<<4;
     secondByte=SPI.transfer(0x00);
     secondByte = secondByte>>4;
     
     byte lightData = (firstByte | secondByte);

     print(lightData);

}

Let me know if you have any more questions.

Thanks,
JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...