Welcome! Log In Create A New Profile

Advanced

Read / Write a port pin with G-Code (maybe M-Code)

Posted by dbhughe 
Read / Write a port pin with G-Code (maybe M-Code)
January 28, 2013 01:44AM
Do any of the prevailing firmwares support reading or writing a port pin? If so, which firmware and what G-Code command. I have a list of control codes that I downloaded from the reprap wiki that makes no mention of this feature but I have read elsewhere that it may exist.

I have worked with PICS (and quite a few other processors) for many years and am now learning Atmega.(can't wait until my development board arrives) In PICS you have to set a corresponding bit in a TRIS (tri-state) register before you can read or write a pin, is that the same in ATmega? The Atmega1284P looks like an awesome 8 bit controller.

Is there a place where all of the firmware derivatives and versions are compared?

Do you know of any pointers, forums or places that I might visit to learn the ins and outs of ATmega controller development.

Thanks for your help
Re: Read / Write a port pin with G-Code (maybe M-Code)
January 28, 2013 03:01AM
Marlin: M42 -Change pin status via gcode,
[github.com]
Re: Read / Write a port pin with G-Code (maybe M-Code)
January 28, 2013 07:54AM
Quote

In PICS you have to set a corresponding bit in a TRIS (tri-state) register before you can read or write a pin, is that the same in ATmega?

Yes. Teacup firmware has SET_INPUT() and SET_OUTPUT() macros for this.

If you're just learning the ATmega ... it might be worth a consideration to go with an ARM based electronics directly. ATmega usage is beyond its ceiling already, higher microstepping usage and higher print speeds make 32-bit CPUs look better suited. If you want me to send you a Gen7-ARM board, drop me a PM.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Read / Write a port pin with G-Code (maybe M-Code)
January 30, 2013 02:45AM
I just got my AVRRISP MKII programmer in the mail today, I bought it used on eBay so that I could develop for AVR, it looks like it handles ARM as well.

Just playing with it tonight I was able turn the stepper motors using my Sanguinololu board. I have definitely not learned the ins and out of ATmega programming yet but I was very happy that I could make it pulse a few pins to control the steppers. It turns out that setting the DDR (TRIS on PIC) resisters is as easy as pie and reading or writing the port pins is similarly easy.

Thanks to everyone who responded to my post, I am sure that I will have some more noob questions to ask of the more experienced.
Sorry, only registered users may post in this forum.

Click here to login