Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Hardware SPI, strange behavior

 
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
rredding

Bascom Member



Joined: 25 Mar 2005
Posts: 63
Location: Tacoma WA

PostPosted: Fri Mar 25, 2005 8:30 pm    Post subject: Hardware SPI, strange behavior Reply with quote

I have an SPI vacuum fluorescent display and SPI real time clock connected to an ATMEGA8 processor. Unfortunately, the VFD likes its bits LSB first and the RTC likes its bits MSB first. So I figured I could just switch back and forth using the CONFIG SPI command and SPIINIT. The trouble is, when I have a second CONFIG SPI command anywhere in the code, even when the part of the code that contains the second CONFIG SPI and SPIINIT is not run through, the VFD stops working, getting garbled or strange text. Does anyone know why this might be happening? Any known fixes?

(Just to be sure that part of the code was not being run, I put a trap in there and the second CONFIG SPI and SPIINIT were not being run.) Things do work OK for the VFD if the second CONFIG SPI does not change the bit order.
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sat Mar 26, 2005 11:14 pm    Post subject: Reply with quote

Try this as a work-around. After you have initially config'd the SPI in the beginning of your program using the CONFIG statement, use the following in the rest of your program to set data order without any further config's or spi inits...

'least significant bit first
SET SPCR.5

'most significant bit first
RESET SPCR.5
Back to top
View user's profile Yahoo Messenger
rredding

Bascom Member



Joined: 25 Mar 2005
Posts: 63
Location: Tacoma WA

PostPosted: Sun Mar 27, 2005 1:05 am    Post subject: That worked! Reply with quote

Thanks for the advice. That solution worked well.
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