Hii
i am very new to MSP430G2231 and i am trying to establish spi link between two launchpads to transfer some data. by assigning the required DATA to USISRL register will transmit the data from one launchpad to other or any PINs have to be used. please help me in this.
thank you
sudeep nandikiby assigning the required DATA to USISRL register will transmit the data from one launchpad to other or any PINs have to be used
Depending on the processor you have on the LaunchPad, different pins are used and in a different way. Some G2 processors have an USI module, some an USCI, and the two are completely different to handle.
However, an PSI communication needs an absolute minimum of 4 wires between the two peers: SOMI, SIMO, SCLK and GND. You may also add VCC if you want to power both from one supply, and a snychronisation signal that is controlled/checked by GPIO. Almost every commercial SPI slave requires such a signal, usually called chip select (CS).And maybe an interrupt signal that tells teh SPI master that the SPi slave has something to tell.
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Hi Jens-Michael Gross
thank you very much , i used slave only in receiving mode and master only in transmitting mode. can you please check the code pasted below. please
master
#include <msp430g2231.h>void main(void){ volatile unsigned int i; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1OUT = 0x10; // P1.4 set, else reset P1REN |= 0x10; // P1.4 pullup P1SEL |=0x06; //P1DIR = 0x01; // P1.0 output, else input USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master USICTL1 |= USIIE; // Counter interrupt, flag remains set USICKCTL = USIDIV_4 + USISSEL_2; // /16 SMCLK USICTL0 &= ~USISWRST; // USI released for operation USISRL = 0X02; // init-load data P1DIR |= 0x04; // Reset Slave P1DIR &= ~0x04; for (i = 0xFFF; i > 0; i--); // Time for slave to ready USICNT = 8; // init-load counterwhile (1) // Loop{ unsigned i; for (i = 0xFFFF; i > 0; i--); // Delay while (!(USIIFG & USICTL1)); // Counter clear? USISRL=0X02; // Read data are ready to be written USICNT = 8; // re-load counter for (i = 0xFFFF; i > 0; i--); USISRL=0X03; USICNT=8;}}
slave
#include <msp430g2231.h>void main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // P1OUT = 0x10; // P1.4 set, else reset // P1REN |= 0x10; // P1.4 pullup //P1DIR = 0x01; // P1.0 output, else input // P1SEL |=0x0A; USICTL0 |= USIPE7 + USIPE5 + USIOE; // Port, SPI slave USICTL1 |= USIIE; // Counter interrupt, flag remains set USICTL0 &= ~USISWRST; // USI released for operation //USISRL = P1IN; // init-load data USICNT = 8; // init-load counter while (1) // Loop { unsigned i,m; for (i = 0xFFFF; i > 0; i--); // Delay while (!(USIIFG & USICTL1)); // Counter clear? m=USISRL; if( m== 0X02) P1OUT |=0x01; else P1OUT &=~0x01; USICNT = 8; // re-load counter }}