Jump to content
touch

SPI 4 digit 7 segment displays

Recommended Posts

Actually, it does work...I used the pins referenced off the page on the Arduino website...!@, looking at the teensy website I see my mistake, its counting now,

 

Looking at the source code how do you get the other 3 digits to light up?

 

--Aaron

Share this post


Link to post
Share on other sites

First digit's address is 0xC0 (and 0xC1, but no segments are connected.)

Second digit's is 0xC2, third is 0xC4, and the last one is 0xC6.

Segments are bit0-bit6 (a-f.)

Colon's dots are connected to bit7 of the first and the second digit.

Share this post


Link to post
Share on other sites

Never mind, found out what was wrong. Was not operating the bit clock at the right frequency. PT6961 supports a minimum frequency of 300kHz, I was using 125kHz. Stupid mistake.

Share this post


Link to post
Share on other sites

I posted an Arduino compatible sketch in the first page of this thread.

viewtopic.php?f=8&t=3225&start=10#p23243

 

I tried this code on an Arduino Due, but I cannot find what is the correct pins to use on that, have been searching all over the Arduino websites, but no.

I found some pinoutguide in the forums, looks like SS is pin 53 and Mosi is pin 51, and there are also an spi header in the middle of the board, tried all of those, but no-go..

 

Energia, is that an arduino compatible IDE for the msp430 launchpad?

Share this post


Link to post
Share on other sites

Sweet, got mine today, just posting a simple USCI_B example for the G2553 that echoes what RobG said for turning on all segments:


#include <msp430.h>
#include <stdint.h>

void spi_init();
uint8_t spi_transfer(uint8_t data);

int main()
{
WDTCTL = WDTPW | WDTHOLD;
DCOCTL = CALDCO_16MHZ;
BCSCTL1 = CALBC1_16MHZ;
BCSCTL2 = DIVS_2; // SMCLK = 8MHz
BCSCTL3 = LFXT1S_2; // ACLK = VLO
__delay_cycles(8000); // Wait for VLO settling
while (BCSCTL3 & LFXT1OF)
;

P1DIR |= BIT1;
P1OUT |= BIT1;
P1SEL &= ~BIT1;
P1SEL2 &= ~BIT1;
__delay_cycles(8000);

spi_init();

P1OUT &= ~BIT1;
spi_transfer(0x02); // Display mode = 6 digits, 12 segments
P1OUT |= BIT1;
P1OUT &= ~BIT1;
spi_transfer(0x40); // Data Write settings; normal, increment addr, write to display mode
P1OUT |= BIT1;
P1OUT &= ~BIT1;
spi_transfer(0x8F); // Display=ON, dimming = maximum brightness (pulse width 14/16)

P1OUT |= BIT1;

P1OUT &= ~BIT1;
spi_transfer(0xC0); spi_transfer(0xFF); // Digit 1 = All segments lit
P1OUT |= BIT1;
P1OUT &= ~BIT1;
spi_transfer(0xC2); spi_transfer(0xFF); // Digit 2 = All segments lit
P1OUT |= BIT1;
P1OUT &= ~BIT1;
spi_transfer(0xC4); spi_transfer(0xFF); // Digit 3 = All segments lit
P1OUT |= BIT1;
P1OUT &= ~BIT1;
spi_transfer(0xC6); spi_transfer(0xFF); // Digit 4 = All segments lit
P1OUT |= BIT1;

LPM4;
return 0;
}

void spi_init()
{
/* Configure ports on MSP430 device for USCI_B */
P1SEL |= BIT5 | BIT6 | BIT7;
P1SEL2 |= BIT5 | BIT6 | BIT7;

/* USCI-B specific SPI setup */
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = UCCKPL | UCMST | UCMODE_0 | UCSYNC; // SPI mode 0, master
UCB0BR0 = 0x01; // SPI clocked at same speed as SMCLK
UCB0BR1 = 0x00;
UCB0CTL1 = UCSSEL_2; // Clock = SMCLK, clear UCSWRST and enables USCI_B module.
}

uint8_t spi_transfer(uint8_t data)
{
UCB0TXBUF = data;
while ( !(IFG2 & UCB0RXIFG) ) // Wait for RXIFG indicating remote byte received via SOMI

;
return UCB0RXBUF;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×