Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Using SPI pin for general I/O

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Martin King

Bascom Member



Joined: 03 Mar 2005
Posts: 12

blank.gif
PostPosted: Mon Feb 09, 2009 7:49 pm    Post subject: Using SPI pin for general I/O Reply with quote

I recently had an issue with Portb.4 on a Mega16. I have a motor running between two soft limits (reed switches) every so often the motor would "glitch" as if one of the limits was being hit and occasionally it would miss one of the soft limits (always the same one) completely and hit the hard limit shutting the system down. Turned out that the affected soft limit was connected to Portb.4 which is one of the SPI lines, moving everything to Portc solved the problem, but I could do with using PortB for general I/O so I guess I have to disable the use of port B for SPI somehow?

Martin.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Feb 09, 2009 10:37 pm    Post subject: Reply with quote

SPI is only enabled if you use the CONFIG SPI = HARD command in Bascom, else it is disabled by default on startup. As long as SPI is not enabled, you should be able to use the port for general I/O.

Be aware some development boards insert resistors into the SPI lines since they are also used for ISP programming. Again, as long as you disconnect the ISP interface, you can use those lines as general I/O.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Martin King

Bascom Member



Joined: 03 Mar 2005
Posts: 12

blank.gif
PostPosted: Mon Feb 09, 2009 11:06 pm    Post subject: Reply with quote

>Be aware some development boards insert resistors into the SPI lines since
>they are also used for ISP programming.

I did wonder about that but B.4 is the SS line and isn't used for programming. It could simply be that that pin is borked, when I get a chance I'll swap it out for a new chip, unfortunately it's now running an automated test which would be a real pain to abort and re-start.

Cheers.
Martin.
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum