Hello Everybody
I would appreciate it very much if someone could help me with the following problem:
My task is to incorporate an SD card (SPI mode) to the EVM430-F6736 Single-Phase Watt-Hour Meter (Application Report SLAA517) using software described in Application Report SLAA281.
After going through the labyrinth of #defines and #includes of the Application Reports, I concluded that I do not know how to enable the 3-pin SPI secondary function that is available in pins P1.7, P2.0 and P2.1 (PM_UCB0CLK, PM_UCB0SOMI and PM_UCB0SIMO respectively) of the MSP430F6736.
To simplify the description of the problem, the code I am using to enable the SPI function in the F6736 is equivalent to the one listed bellow.
I am monitoring pins PM_UCB0CLK and PM_UCB0SIMO with an oscilloscope, and there is simply NO ACTIVITY at all. What is wrong?
Thanks
Claudio R. Sonnenburg
#include <stdio.h>
#include <msp430f6736.h>
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;
// CLOCK and SIMO (P1.7, P2.1) are outputs
P2OUT |= BIT1;
P2DIR |= BIT1; // SIMO
P1OUT |= BIT7;
P1DIR |= BIT7; // CLOCK
// Enable secondary functions of pins P1.7, P2.0 and P2.1
P1SEL |= BIT7; // SPI CLOCK
P2SEL |= BIT0 + BIT1; // SOMI and SIMO
// enable port mapping
PMAPPWD = 0x02D52;
PMAPCTL |= PMAPRECFG;
// port mapping for eUSCI_B0 SPI default secondary function
P2MAP0 = PM_UCB0SOMI;
P2MAP1 = PM_UCB0SIMO;
P1MAP7 = PM_UCB0CLK;
// Enable secondary functions of pins P1.7, P2.0 and P2.1
//P1SEL |= BIT7; // SPI CLOCK
//P2SEL |= BIT0 + BIT1; // SOMI and SIMO
// Init SPI Module
UCB0CTL1 = UCSWRST;
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0CTL0 = UCMST+UCCKPL+UCMSB+UCSYNC; // 3-pin, 8-bit SPI master
UCB0BR1 = 0;
UCB0BR0 |= 0x40; // UCLK/64
UCB0CTL1 &= ~UCSWRST;
for(int z=0;z<=9;z++)
{
while((UCB0IFG & UCTXIFG) == 0); // hold till TX gets empty
UCB0TXBUF = 0xff; // send byte
}
}