Part Number: MSP430F5529
Tool/software: Code Composer Studio
Dear sir,
This is Vikash chandra Raman from Comcon-Industries. I am doing a project related to measure the current as well as voltages. For measuring the current and voltages i am using a MSP430F5529 controller interfacing with spi communications( 4 wire communications).
I have to send 32 bit data and also recieve the 32 bit data on SOMI(RX) pin.
I have send the data of 32 bit along with address , but when i recieve the data it only recieve 8 bit data on somi pin. I request you kindly check my code or give me some idea how to recieve 32 bit data on somi pins.
For setup SPI communication i am using the following registers as well as whole codes
#include <msp430.h>
short int arry[32]={0};
short int *value=arry;
unsigned int i=0,size=0,Flag=0;
void PinSetup()
{
/*CS1*/
P4DIR|=BIT0;
/*CS2*/
P3DIR|=BIT7;
P3OUT|=BIT7;
/*CS3*/
P3DIR|=BIT6;
P3OUT|=BIT6;
}
void init_UCB1(void)
{
P4SEL|=BIT1+BIT2+BIT3;
UCB1CTL1 |= UCSWRST;
UCB1CTL0 = UCCKPH + UCCKPL + UCMST + UCMODE_1 + UCSYNC; //UCB0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB;
UCB1CTL1 = UCSSEL_2;
//UCB0BR0 = 255;
UCB1CTL1 &=~UCSWRST;
UCB1IE |= UCRXIE;
}
void send( int data,int i)
{
int l;
__disable_interrupt();
l=data;
l=l>>8;
while(i){
while(!( UCB1IFG & UCTXIFG));
UCB1TXBUF = l;
l=data;
i--;
}
while(UCB1STAT & UCBUSY);
__enable_interrupt();
}
void send_8bit( int data,int i)
{
__disable_interrupt();
while(i){
while(!( UCB1IFG & UCTXIFG));
UCB1TXBUF = data;
i--;
}
while(UCB1STAT & UCBUSY);
__enable_interrupt();
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
PinSetup();
init_UCB1();
/*Custmer access code (0x4F70656E) WITH ADDRESS 0x2F*/
P4OUT&=~BIT0;
/*READ_1 && WRITE_0*/
send_8bit(0x2F,1);
send(0x6E65,2);
send(0x704F,2);
// P4OUT|=BIT0;
while(1){
// __delay_cycles(1234);
P4OUT&=~BIT0;
send_8bit(0xA0,1);//? READ OR WRITE??
send(0x0000,2);
send(0x0000,2);
// __delay_cycles(4321);
// P4OUT|=BIT0;
value=arry;
}
}
#pragma vector=USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
switch(__even_in_range(UCB1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
// for(i=0;i<32;i++)
// {
// if(i==32){
// Flag=1;
// UCB1IFG &=~ UCRXIFG;
// break;}
while (!(UCB1IFG & UCTXIFG));
*value = UCB1RXBUF;
value++;
// }
// __bis_SR_register(GIE);
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
Kindly suggest me a answer so that i am able to read 32 bit data on SOMI pins.
waiting for your positive response
Vikash chandra raman
Comcon industries
New -Delhi