I am doing an independent study at my univ. and am having a very tough time getting my SPI LCD Screen to display text. The scope of the study is to use the cc430f6137rf900 development board kit to read in a temperature, then transmit the info to the other board and display temp on the recieving board (using an LCD with a SPI comm protocol). Currently, I am just trying to get the LCD to display "Hello World!" on one board before I move forward with the project so I haven't even began to mess with the RF part as of yet, or the temperature sensor. So basically I am just stuck and it is beginning to become frustrating. This is my first semester coding microcontrollers and my c programming skills are ok, not great though. So obviously I am just a beginner and I just really need a shove in the right direction. The LCD with SPI I am using is a NewHaven model NHD‐C0216CZ‐NSW‐BBW‐3V3. If anyone has any suggestions on the code, it would be much appreciated. I have also attached a users guide/datasheet for the LCD along with the user's guide for the 430. I have spent hours and hours already going through the material but I must have missed something because it is still not working. Here is the code I have so far:
#include "cc430x613x.h" #define LED1 BIT0 // P1.0 #define RST BIT2 // P1.2 LCD Active Low Reset Signal #define RS BIT3 // P1.3 Register Select RS=0:instruction,RS=1:data #define CS BIT4 // P1.4 Active Low Chip Select signal unsigned int TxData[] = {0x30,0x30,0x39,0x14,0x56,0x6D,0x70,0x0C,0x06,0x01}; unsigned int TxData2[] = {'H','e','l','l','o',' ','W', 'o', 'r', 'l', 'd','!'}; void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer PMAPPWD = 0x02D52; // Get write-access to port mapping regs P2MAP0 = PM_UCA0SIMO; // Map UCA0SIMO output to P2.0 P2MAP2 = PM_UCA0SOMI; // Map UCA0SOMI output to P2.2 P2MAP4 = PM_UCA0CLK; // Map UCA0CLK output to P2.4 P2MAP6 = PM_UCA0STE; // Map UCA0STE output to P2.6 PMAPPWD = 0; // Lock port mapping registers P1OUT |= RST + CS; // Set P1.0 for LED // Set P1.2 for slave reset P1DIR |= BIT0 + BIT2 + BIT3 + BIT4; // Set P1.0, P1.2 to output direction P2DIR |= BIT0 + BIT2 + BIT4 + BIT6; // ACLK, MCLK, SMCLK set out to pins P2SEL |= BIT0 + BIT2 + BIT4 + BIT6; // P2.0,2,4 for debugging purposes. UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL0 |= UCMODE_1; // 4- pin? UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master // Clock polarity high, MSB UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 0x02; // /2 Prescale Bits UCA0BR1 = 0; // UCA0MCTL = 0; // No modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** UCA0IE |= UCTXIE; // Enable USCI_A0 TX interrupt // Now with SPI signals initialized, P1OUT &= ~RST; // reset slave __delay_cycles(50); P1OUT |= RST + CS; // take out of reset and set chip // select high // **************************************************************************** __delay_cycles(10); P1OUT &= ~CS; P1OUT &= ~RS; // command unsigned int cnt2; for (cnt2 = 0; cnt2 < 10; cnt2++){ // LCD int UCA0TXBUF = TxData[cnt2]; __delay_cycles(100); } UCA0TXBUF = 0x31; // contrast? __delay_cycles(100); UCA0TXBUF = 0x02; // home P1OUT |= CS; P1OUT |= RS; // data __delay_cycles(50); P1OUT &= ~CS; for (cnt2 = 0; cnt2 < 12; cnt2++){ // LCD txt UCA0TXBUF = TxData2[cnt2]; __delay_cycles(100); } __delay_cycles(20); P1OUT |= CS; __bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts } #pragma vector=USCI_A0_VECTOR __interrupt void USCI_A0_ISR(void) { switch(__even_in_range(UCA0IV,4)) { case 0: break; // Vector 0 - no interrupt case 2: break; // Vector 2 - RXIFG case 4: // Vector 4 - TXIFG ; default: break; } }
]