CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Bit Banging with no UART

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
StingzLD



Joined: 18 Jul 2010
Posts: 42
Location: Richmond, VA

View user's profile Send private message

Bit Banging with no UART
PostPosted: Sun Jul 18, 2010 2:28 pm     Reply with quote

Hey Guys!

I am a novice in need of some assistance. I am new to the C language, and I cannot figure out how to bit bang my microcontroller! I am using a PIC16F684, which means there is no UART Sad . I need help figuring out how to bit bang a 16-bit packet to the MAX7219 LED Driver. (The datasheet PDFs are the hyperlinks for the chips). How the data is to be sent to the MAX7219 is on page 7 (or 8 of the actual PDF). I get how the driver wants the information sent, but I just don't understand how to bit bang the packet into DIN. Oh, I guess telling you the pin mapping might be helpful! Haha

PIC = MAX
RC0 (Pin 10) = DIN (Pin 1)
RC1 (Pin 9) = LOAD (Pin 12)
RC2 (Pin 8) = CLK (Pin 13)

Any help will be greatly appreciated.

Thanks in advance! Very Happy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 18, 2010 2:43 pm     Reply with quote

Use the forum's search page. There's a link for it at the top of the forum.
I did that and found exactly what you need in the Code Library forum.
A bit-banged SPI driver for the Max7219:
http://www.ccsinfo.com/forum/viewtopic.php?t=38882

Also, you wouldn't use a UART to do SPI. You would use the MSSP
module in the PIC. Or do it in software, as shown in the link above.

If you need more help, search for Max7219. There are over a dozen
posts on it in the forum archives.
StingzLD



Joined: 18 Jul 2010
Posts: 42
Location: Richmond, VA

View user's profile Send private message

PostPosted: Sun Jul 18, 2010 3:06 pm     Reply with quote

Awesome. Thanks!
StingzLD



Joined: 18 Jul 2010
Posts: 42
Location: Richmond, VA

View user's profile Send private message

PostPosted: Sun Jul 18, 2010 4:45 pm     Reply with quote

Okay. So I printed out that code, and sat down to try and understand it. But I think I am a little confused about what is going on. In the MAX7219.c, he mentions reverse more than once. What exactly is it reversing? Is it the lower 8 bits (D7-D0, the segments)? If it is, can I just delete the section "unsigned int8 reverse" and the code "dis_data=reverse(dis_data); [in the 'void display' section]" if I don't want them reversed? Like I said, I am a novice; and changing things from what the data sheet says will probably confuse me later down the road when I go to rewrite/debug and can't figure out what is going wrong with my main.c code.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

Reversing
PostPosted: Tue Jul 20, 2010 12:24 am     Reply with quote

See the function called reverse (unsigned int8 reverse(unsigned int8 nd_data))

An explanation above the function explains why this needs to be done.

You can also use the MPLAB simulator and step through the code.

thanks
a
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group