программа комплилируется и зашивается.
пример программы взять с ти.сом но что то не работает .
с даташитами большая проблема не могу в них разобраться.
ниже приведен текст программы
Код
#include <msp430f5515.h>
unsigned long int MST_Data,SLV_Data;
unsigned char temp;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P4SEL |= BIT1+BIT2+BIT3; // P3.3,4 option select
UCB1CTL1 |= UCSWRST; // **Put state machine in reset**
UCB1CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
UCB1CTL1 |= UCSSEL_2; // SMCLK
UCB1BR0 = 0x02; // /2
UCB1BR1 = 0; //
// No modulation
UCB1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCB1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
P1OUT &= ~0x02; // Now with SPI signals initialized,
P1OUT |= 0x02; // reset slave
for(i=50;i>0;i--); // Wait for slave to initialize
MST_Data = 0x20; // Initialize data values
SLV_Data = 0x00; //
while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCB1TXBUF = 0x80; // Transmit first character
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x60;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x11;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x10;
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}
#pragma vector=USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
volatile unsigned int i;
switch(__even_in_range(UCB1IV,4))
{
case 0: break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// Increment data
SLV_Data++;
// UCB1TXBUF = MST_Data; // Send next value
for(i = 20; i>0; i--); // Add time between transmissions to
// make sure slave can process information
break;
case 4: break; // Vector 4 - TXIFG
default: break;
}
}
unsigned long int MST_Data,SLV_Data;
unsigned char temp;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P4SEL |= BIT1+BIT2+BIT3; // P3.3,4 option select
UCB1CTL1 |= UCSWRST; // **Put state machine in reset**
UCB1CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
UCB1CTL1 |= UCSSEL_2; // SMCLK
UCB1BR0 = 0x02; // /2
UCB1BR1 = 0; //
// No modulation
UCB1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCB1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
P1OUT &= ~0x02; // Now with SPI signals initialized,
P1OUT |= 0x02; // reset slave
for(i=50;i>0;i--); // Wait for slave to initialize
MST_Data = 0x20; // Initialize data values
SLV_Data = 0x00; //
while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCB1TXBUF = 0x80; // Transmit first character
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x60;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x11;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x10;
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}
#pragma vector=USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
volatile unsigned int i;
switch(__even_in_range(UCB1IV,4))
{
case 0: break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// Increment data
SLV_Data++;
// UCB1TXBUF = MST_Data; // Send next value
for(i = 20; i>0; i--); // Add time between transmissions to
// make sure slave can process information
break;
case 4: break; // Vector 4 - TXIFG
default: break;
}
}
пояснения
" while (!(UCB1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCB1TXBUF = 0x80; // Transmit first character
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x60;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x11;
while (!(UCB1IFG&UCTXIFG));
UCB1TXBUF = 0x10;"
передаю данные , ну или я так думаю именно последовательность этих данных нужна для срабатывания дисплея
что делается по прерыванию пока не понял
подскажите кто чем может