Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 225245

Forum Post: RE: MSP430G2553: CC1101 programming using msp430g2553

$
0
0
Thanks Tomasz, Please update me accordingly. I just saw a youtube video on how to interface SPI device with launchpad and I can see that he has linked MOSI of SPI slave with MISO of launch pad and vice versa(please find youtube video link). I am not sure what I am doing wrong. To me following could be the possibilities: IC issue, SPI pins not working?? Connections are wrong: At the moment I connect SCK pin of cc1101 with pin 7(P1_5) of the launch pad,csn with pin 8 (configure as output P2_0). MOSI with pin 14(P1_6) and MISO with pin 15(P1_7) Energia not initializing the SPI library properly I use SPI.begin() to initiliaze the SPI library which calls the following code void spi_initialize(void) { UCB0CTL1 = UCSWRST | UCSSEL_2; // Put USCI in reset mode, source USCI clock from SMCLK UCB0CTL0 = SPI_MODE_0 | UCMSB | UCSYNC | UCMST; // Use SPI MODE 0 - CPOL=0 CPHA=0 /* Set pins to SPI mode. */ pinMode_int(SCK, SPISCK_SET_MODE); pinMode_int(MOSI, SPIMOSI_SET_MODE); pinMode_int(MISO, SPIMISO_SET_MODE); UCB0BR0 = SPI_CLOCK_DIV() & 0xFF; // set initial speed to 4MHz UCB0BR1 = (SPI_CLOCK_DIV() >> 8 ) & 0xFF; UCB0CTL1 &= ~UCSWRST; // release USCI for operation } After caling this library I set the clock rate, MSB data format, and polarity by calling the following functions void spi_set_divisor(const uint16_t clkdiv) //set clock rate { UCB0CTL1 |= UCSWRST; // go into reset state UCB0BR0 = clkdiv & 0xFF; UCB0BR1 = (clkdiv >> 8 ) & 0xFF; UCB0CTL1 &= ~UCSWRST; // release for operation } /** * spi_set_bitorder(LSBFIRST=0 | MSBFIRST=1) */ void spi_set_bitorder(const uint8_t order) { UCB0CTL1 |= UCSWRST; // go into reset state UCB0CTL0 = (UCB0CTL0 & ~UCMSB) | ((order == 1 /*MSBFIRST*/) ? UCMSB : 0); /* MSBFIRST = 1 */ UCB0CTL1 &= ~UCSWRST; // release for operation } /** * spi_set_datamode() - mode 0 - 3 */ void spi_set_datamode(const uint8_t mode) // set polarity and phase { UCB0CTL1 |= UCSWRST; // go into reset state switch(mode) { case 0: /* SPI_MODE0 */ UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_0; break; case 1: /* SPI_MODE1 */ UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_1; break; case 2: /* SPI_MODE2 */ UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_2; break; case 4: /* SPI_MODE3 */ UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_3; break; default: break; } UCB0CTL1 &= ~UCSWRST; // release for operation } I am not expert in assembly language so please advise accordingly. thank you everyone for support (Please visit the site to view this video)

Viewing all articles
Browse latest Browse all 225245

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>