![]() |
Forum Index : Microcontroller and PC projects : Help matherp!
Author | Message | ||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Peter, I needed a Cfunction routine to write data to the SPI port on a MX170, so I carved out the SPI code from your OLED driver. Things are working great (so far), but I may need to alter a couple of settings. This is where I need your help. I would like to change the 8 bit output to 16 bit or maybe even to 32 bit (16 prefered). What bits need to be changed in config1 to achieve that? Also, I may wish to change the SPI port speed... is that possible or do I need a degree in quantum-hyper-mathematics? ![]() Thanks, Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10251 |
To set to 16 or 32 bit you have to go to the SPI part of the MX170 manual page 167. There is no short cut on this stuff the manual is the reference. To set different speeds I always cheat ![]() |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Bummer! ![]() Thanks, Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Ooops! I've got my bit/byte conversion all screwed up in my head. ![]() --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10251 |
was trying not to spoonfeed ![]() This one is really easy, just set bit 11 in SPI1CON and you are in 32-bit mode. bit 10 set, bit 11 clear = 16-bit bit 10 clear, bit 11 clear = 8-bit bit 10 don't care, bit 11 set = 32-bit We are not in "audio" mode so you can ignore AUDEN, it is always set to zero Actually though it makes little difference to speed as we are using SPI in a blocking mode waiting for the bits to shift out before reloading |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Peter, I'm not looking for a "spoonfeed" which is why I asked about which bits to change. Even though it really is the same answer either way, I was interested in trying to related the bits with the rest of the configuration information. Your pointing me to the proper docs and page was a great help. That information showed me I was making a really stupid conversion mistake. What has me confused now is I know the SPI port is working in 8 bit mode, but as I read bits 10 and 11, it looks like it is configured for 32 bit mode. #define SPICON *(volatile unsigned int *)(0xbf805800) //SPI config 1 register
0xbf805800 in binary would be: 1011 1111 1000 0000 0101 1000 0000 0000 .... .... .... .... .... ^... .... .... Isn't that bit 11 set? Or, am I looking at this all wrong? --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
CircuitGizmos![]() Guru ![]() Joined: 08/09/2011 Location: United StatesPosts: 1427 |
Have I not had enough coffee? Are you looking at the address rather than the data at that address? Micromites and Maximites! - Beginning Maximite |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10251 |
CircuitGizmos is absolutely correct. The #define creates a variable label within the compiler where the contents of that variable are stored at the physical address 0xbf805800. Volatile tells the compiler that the contents may change while the code is running so not to optimise by taking a local copy i.e. read it afresh each time it is used. So in Basic go SPI OPEN 1000000,3,8. Then in Basic you can "print hex$peek(word &Hbf805800))" to read the contents of the register. If you do that you should see bit 11 isn't set. Then try SPI OPEN 1000000,3,32 and peek again, it should now be set |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Of course it's the address not the configuration I've been looking at. I see it now! I hate C ! ![]() Thank you both! --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2949 |
Curt, Shouldn't that be I C it now! I hate see? ![]() Curtis, I am pretty impressed at how quickly you have adapted to C.. I know I could never do it, or can I? You have shamed me into giving it another go, the speed improvement you mentioned in PM to me sounds absolutely awesome. Keep up the good work. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Come on and join the fun Mick! In 30 days you can be just as lost as I am now with C. ![]() --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
Lou![]() Senior Member ![]() Joined: 01/02/2014 Location: United StatesPosts: 229 |
Mick, Looks like you have just lost a beloved member of your family. My condolences, I am very sorry. Lou Microcontrollers - the other white meat |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |