Mesa Serial Connection / GPIO question

09 Jan 2017 02:42 #85498 by BishopCNC15
BishopCNC15 created the topic: Mesa Serial Connection / GPIO question

First question: I read in the Mesa documentation that the FPGA is able to create a serial connection using the GPIO pins. I have a 5i23. I'd like to make an I2C or SPI connection to an analog to digital converter I have. My end goal is to use this to control temperature on a 3D printer nozzle and heat bed. How can I set this up in pncconf / HAL?

Second question: If I select SVST8_4 (8 encoder, 8 pwm, 4 stepper) and reduce the number of steppers to zero in pncconf, will they return to being GPIO? I don't have any stepper motors to use but I'd like the extra GPIO. Just want to make sure a custom bit file isn't needed for that.

Final question: This is kind of an afterthought - can I just write something in C++ or python (or anything really) to directly control the 5i23's pins?

17 Jan 2017 13:25 #85915 by andypugh
andypugh replied the topic: Mesa Serial Connection / GPIO question
Yes, unused pins become GPIO.

You can write a HAL component that uses GPIO to directly drive pins. There is an example here
which pin-bangs GPIO to read a temperature sensor chip.

It is written using this pre-processor code:

This has a max data rate of no more than 1kHz (probably half that, actually) because it runs in the servo thread.
For higher data rates you could use a Mesa firmware that includes BSPI channels, and write a .comp driver to control that directly.
Accessing BSPI on the Mesa card from a .comp is a bit of a fiddle, but there is an example of doing that here:

And a similar example accessing a serial UART from a Mesa firmware:

Mesa bitfiles such as ...svssua... have UARTS (ua = uart, sv = servo encoder / pwm, st = stepgens)
The following user(s) said Thank You: BishopCNC15
Moderators: cmorley
Time to create page: 0.055 seconds
Powered by Kunena Forum