Reputation: 592
I'm using an MSP430 Launchpad. To be more specific I'm using the microcontroler MS430G2553. I was trying to compile some code designed for the MS430G2230 but the problem is that some parts of the code wont match the MS430G2553. This is the code
void USI_Init (void)
{
// configure SPI
USICTL0 |= USISWRST; // USI in reset
USICTL0 = USICTL0 | USILSB; // Least Significant Bit first
USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI Master
USICTL1 |= USICKPH; // flag remains set
USICKCTL = USIDIV_1 + USISSEL_2; // /2 SMCLK
USICTL0 &= ~USISWRST; // USI released for operation
USICNT = USICNT | 0x50; // 16 bit mode; 16 bit to be transmitted/received
return;
}
and this is the second routine that doesn't work
#pragma vector=WDT_VECTOR
__interrupt void Write_Matrix(void)
{
static unsigned char index=0;
P1OUT |= DATA_LATCH_PIN;
P1OUT &= ~DATA_LATCH_PIN;
USICTL1 &= ~USIIFG; // Clears the interrupt flag
USISRH = 1<<index; // Move the index of the column in the high bits of USISR
USISRL = Matrix[index]; // Move the index of the rows (value of Matrix[index]) in the low bits of USIRS
USICNT = USICNT | 0x10; // 16 bit format
index = (index+1) & 7;
return;
}
Any Ideas? Thanks
Upvotes: 0
Views: 573
Reputation: 2483
First off, you shouldn't expect to have code that is 100% portable between those two families of processors. The MSP430G2553 is a much larger value line processor and comes with more peripherals than the MSP430G2230.
Please refer to the following diagrams:
As you can see, these MCUs are very different.
Your first routine doesn't work because the MSP430G2553 doesn't have a USI
peripheral. Instead, SPI communication is performed using a USCI
peripheral. You will need to modify your code to use this peripheral instead. Please reference the User's Guide for more information.
Your second routine doesn't work because of the lack of USI
peripheral again. Notice the references to USI
registers: USICTL1 &= ~USIIFG;
, etc. You will need to once again modify your code to use the USCI
peripheral.
Upvotes: 2