Sign in

Not a member? | Forgot your Password?

Search msp430

Search tips

Subscribe to msp430

Free PDF Downloads

Beginning Microcontrollers with the MSP430

Advanced Linux Programming

What Every Programmer Should Know About Memory

Introduction to Embedded Systems

C++ Tutorial

Embedded Systems - Theory and Design Methodology

Microcontroller Programming and Interfacing

Introduction to Microcontrollers


More Free PDF Downloads

Discussion Groups

See Also

ElectronicsDSPFPGA

Discussion Groups | MSP430 | SPI bit-banging examples?

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

SPI bit-banging examples? - Richard Cooke - Jun 27 14:25:56 2007

Hi Folks,

I need to use the MSP430F2111 due to cost issues (and at least 16 I/0)
but I also need to interface to a Nordic RF chip via SPI. This
particular flavor of MSP doesn't have a hardware SPI port so I'm stuck
with bit-banging.

Can some kind soul point me to an example or framework that shows this
bit-banging of a SPI interface.

Thanks,

Richard Cooke

Re: SPI bit-banging examples? - Stuart_Rubin - Jun 28 9:55:09 2007

There's nothing to bit-banging. Just look at the data sheet for the
chip you're talking to and flip the bits! There aren't too many
canned examples of this because when people are bit-banging, it's
because they have special needs.

You could:
Setup a timer ISR at 2x your bit rate.
For writing:
Every odd-numbered ISR take your data bit, mask out the LSBit, put it
on our data port. Toggle your clock port bit.
Ever even-numbered ISR, toggle your clock bit.
For reading:
Do the same as writing, but shift IN data bits.

You can do it!

Stuart

--- In m..., "Richard Cooke" wrote:
>
> Hi Folks,
>
> I need to use the MSP430F2111 due to cost issues (and at least 16 I/0)
> but I also need to interface to a Nordic RF chip via SPI. This
> particular flavor of MSP doesn't have a hardware SPI port so I'm stuck
> with bit-banging.
>
> Can some kind soul point me to an example or framework that shows this
> bit-banging of a SPI interface.
>
> Thanks,
>
> Richard Cooke
>


Re: SPI bit-banging examples? - Crane - Jun 28 12:40:56 2007

I agree with Rubin. You need four wires: Select, Data Out, Data In and Clock.
Select the device, raise or lower Data Out, raise and then lower the Clock,
Test Data In for a bit.

As Rubin points out the actual routine will be defined by the data sheet of
the device you are driving.

Crane

Richard Cooke-2 wrote:
>
> Hi Folks,
>
> I need to use the MSP430F2111 due to cost issues (and at least 16 I/0)
> but I also need to interface to a Nordic RF chip via SPI. This
> particular flavor of MSP doesn't have a hardware SPI port so I'm stuck
> with bit-banging.
>
> Can some kind soul point me to an example or framework that shows this
> bit-banging of a SPI interface.
>
> Thanks,
>
> Richard Cooke
>

--

_____________________________
 Free pdf download: Beginning Microcontrollers with the MSP430.


Re: SPI bit-banging examples? - mago Umandam - Jun 28 20:09:45 2007

When i made code to bitbang an spi device (AT25040N), i started from this TI sample code.
I hope this helps..

regards,
mago

#include
#define CS 0x01 // P2.0 - Chip Select
#define CLK 0x02 // P2.1 - Clock
#define DO 0x08 // P2.3 - Data Out
void main (void)
{
unsigned char ADCData;
unsigned char Counter;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P2OUT = CS; // /CS set, - P2.x reset
P2DIR |= CLK + CS; // /CS and CLK outputs
P1DIR |= 0x01; // Set P1.0 to output direction
for (;;) // Infinite loop
{
P2OUT &= ~CS; // /CS reset, enable ADC
for (Counter = 8; Counter > 0;)
{
ADCData = ADCData << 1;
if ((P2IN & DO) == DO)
{
ADCData |= 0x01;
}
Counter --;
P2OUT |= CLK; // Clock high
P2OUT &= ~CLK; // Clock low
}
P2OUT |= CS; // /CS set, disable ADC
if (ADCData < 0x7F)
{
P1OUT &= ~0x01; // Clear P1.0 LED off
}
else
{
P1OUT |= 0x01; // Set P1.0 LED on
}
}
}

Stuart_Rubin wrote:
There's nothing to bit-banging. Just look at the data sheet for the
chip you're talking to and flip the bits! There aren't too many
canned examples of this because when people are bit-banging, it's
because they have special needs.

You could:
Setup a timer ISR at 2x your bit rate.
For writing:
Every odd-numbered ISR take your data bit, mask out the LSBit, put it
on our data port. Toggle your clock port bit.
Ever even-numbered ISR, toggle your clock bit.
For reading:
Do the same as writing, but shift IN data bits.

You can do it!

Stuart

--- In m..., "Richard Cooke" wrote:
>
> Hi Folks,
>
> I need to use the MSP430F2111 due to cost issues (and at least 16 I/0)
> but I also need to interface to a Nordic RF chip via SPI. This
> particular flavor of MSP doesn't have a hardware SPI port so I'm stuck
> with bit-banging.
>
> Can some kind soul point me to an example or framework that shows this
> bit-banging of a SPI interface.
>
> Thanks,
>
> Richard Cooke
>

---------------------------------
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.

Re: SPI bit-banging examples? - Microbit - Jun 28 21:53:50 2007

It's also a good idea to leave the clock high (in this example SPI mode) before deasserting
CS. Some SPI devices will require this. (add marked by ****)

for (Counter = 8; Counter > 0;)
{
ADCData = ADCData << 1;
if (P2IN & DO)
{
ADCData |= 0x01;
}
Counter --;
P2OUT |= CLK; // Clock high
P2OUT &= ~CLK; // Clock low
}
P2OUT |= (CLK + CS); // Clock high BEFORE strobing ***
// /CS set, disable ADC

I do realise this was simple example code of course.

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of mago Umandam
Sent: Friday, 29 June 2007 10:10 AM
To: m...
Subject: Re: [msp430] Re: SPI bit-banging examples?

When i made code to bitbang an spi device (AT25040N), i started from this TI sample code.
I hope this helps..

regards,
mago

#include
#define CS 0x01 // P2.0 - Chip Select
#define CLK 0x02 // P2.1 - Clock
#define DO 0x08 // P2.3 - Data Out
void main (void)
{
unsigned char ADCData;
unsigned char Counter;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P2OUT = CS; // /CS set, - P2.x reset
P2DIR |= CLK + CS; // /CS and CLK outputs
P1DIR |= 0x01; // Set P1.0 to output direction
for (;;) // Infinite loop
{
P2OUT &= ~CS; // /CS reset, enable ADC
for (Counter = 8; Counter > 0;)
{
ADCData = ADCData << 1;
if ((P2IN & DO) == DO)
{
ADCData |= 0x01;
}
Counter --;
P2OUT |= CLK; // Clock high
P2OUT &= ~CLK; // Clock low
}
P2OUT |= CS; // /CS set, disable ADC
if (ADCData < 0x7F)
{
P1OUT &= ~0x01; // Clear P1.0 LED off
}
else
{
P1OUT |= 0x01; // Set P1.0 LED on
}
}
}

Re: SPI bit-banging examples? - bori...@hotmail.com - Aug 7 11:46:35 2007

Hi everybody !

I don't really know how does work a bit-banging... Anyway, I am looking for advice or code sample to help me to program a software to use SPI to write/read data into/from an external flash (AT45DB642D). I'm already using the two USART ports of the MSP430F1611... Consequently I have to program it entirely in C or asm using for example P4.0,P4.1,P4.2, P4.3 pins as CS, SIMO, SOMI, CLK...

Anybody can help me ?

Thanks

Re: SPI bit-banging examples? - bori...@hotmail.com - Aug 8 5:00:26 2007

Hi everybody !

I don't really know how does work a bit-banging... Anyway, I am looking for advice or code sample to help me to program a software to use SPI to write/read data into/from an external flash (AT45DB642D). I'm already using the two USART ports of the MSP430F1611... Consequently I have to program it entirely in C or asm using for example P4.0,P4.1,P4.2, P4.3 pins as CS, SIMO, SOMI, CLK...

Anybody can help me ?

Thanks

Re: SPI bit-banging examples? - Leon - Aug 8 5:25:50 2007

http://webspace.webring.com/people/jl/leon_heller/
----- Original Message -----
From:
To:
Sent: Wednesday, August 08, 2007 9:58 AM
Subject: [msp430] Re: SPI bit-banging examples?
> Hi everybody !
>
> I don't really know how does work a bit-banging... Anyway, I am looking
> for advice or code sample to help me to program a software to use SPI to
> write/read data into/from an external flash (AT45DB642D). I'm already
> using the two USART ports of the MSP430F1611... Consequently I have to
> program it entirely in C or asm using for example P4.0,P4.1,P4.2, P4.3
> pins as CS, SIMO, SOMI, CLK...
You simply set the data pin high or low, and toggle the clock. All the
details you need will be in the flash chip data sheet. Look at the TI FET
examples for some typical code, like the software SPI for the TLC549.

Leon
--
Leon Heller
Amateur radio call-sign G1HSM
Yaesu FT-817ND and FT-857D transceivers
Suzuki SV1000S motorcycle
l...@btinternet.com

Re: SPI bit-banging examples? - mukry - Aug 13 15:07:47 2007

Hello,

you can find the spi bit-banging example in TI application note "MSP430
Interface to CC1100/2500 Code Library". C Code is also provided with this
application note in which SPI bit.banging is also implemented.

Mukry

Bobish wrote:
>
> Hi everybody !
>
> I don't really know how does work a bit-banging... Anyway, I am looking
> for advice or code sample to help me to program a software to use SPI to
> write/read data into/from an external flash (AT45DB642D). I'm already
> using the two USART ports of the MSP430F1611... Consequently I have to
> program it entirely in C or asm using for example P4.0,P4.1,P4.2, P4.3
> pins as CS, SIMO, SOMI, CLK...
>
> Anybody can help me ?
>
> Thanks

--

Re: SPI bit-banging examples? - Boris DE BOSSOREILLE - Aug 13 16:17:36 2007

Thanks Mukry ! I think I will find everything I want in the Applicaton Note N49 by selecting SPI BitBang config !

Have a nice day !

Bobish
To: m...From: p...@yahoo.comDate: Sun, 12 Aug 2007 02:16:22 -0700Subject: Re: [msp430] SPI bit-banging examples?

Hello,you can find the spi bit-banging example in TI application note "MSP430Interface to CC1100/2500 Code Library". C Code is also provided with thisapplication note in which SPI bit.banging is also implemented.Mukry Bobish wrote:> > Hi everybody !> > I don't really know how does work a bit-banging... Anyway, I am looking> for advice or code sample to help me to program a software to use SPI to> write/read data into/from an external flash (AT45DB642D). I'm already> using the two USART ports of the MSP430F1611... Consequently I have to> program it entirely in C or asm using for example P4.0,P4.1,P4.2, P4.3> pins as CS, SIMO, SOMI, CLK...> > Anybody can help me ?> > Thanks > > --
_________________________________________________________________
Besoin d'un e-mail ? Crz gratuitement un compte Windows Live Hotmail et gagnez du temps avec l'interface la Outlook !
http://www.windowslive.fr/hotmail/default.asp

_____________________________
 Free pdf download: Beginning Microcontrollers with the MSP430.