
pfactorial
-
Content Count
84 -
Joined
-
Last visited
Reputation Activity
-
pfactorial reacted to gwdeveloper in One last BMP085 Project...
Ok, so the MSP-EXP430F5529 dev board may not provide me with optimal hardware I/O for my greenhouse controller. Basically, I'd want the power/speed of the F5529 without the accelerometer. If I were rebuilding this board, I'd move the LCD SPI over to UCA1 and free up UCB1 for an I2C channel. UCB0 is being used for the RF2500t interface. So...
My solution (for now) is to use a standalone G2553 as an I2C to UART translator. It actually works out well but not my optimal hardware configuration. This project may not be useful for many but some might find bits of the code helpful. The kicker, though, is I configured all of the hardware using Grace. :crazy:
If you have a BMP085, you can open a terminal on your launchpad port and receive temperature and barometric pressure.
/****************************************************************/ /* Greg Whitmore */ /* greg@gwdeveloper.net */ /* www.gwdeveloper.net */ /****************************************************************/ /* released under the "Use at your own risk" license */ /* use it how you want, where you want and have fun */ /* debugging the code. */ /* MSP-EXP430G2553 */ /****************************************************************/ /* includes */ #include #include #include #include "itoa.h" /* bmp085 defines */ #define BMP085_ADDR 0x77 #define BMP085_CTRL_REG 0xF4 #define BMP085_TEMP_REG 0x2E #define BMP085_PRESSURE_REG 0x34 // oss =0 //#define BMP085_PRESSURE_REG_OSS1 0x74 // oss =1, longer delays needed 7.5ms //#define BMP085_PRESSURE_REG_OSS2 0xB4 // oss =2, 13.5ms //#define BMP085_PRESSURE_REG_OSS3 0xF4 // oss =3, 25.5ms #define BMP085_MSB_REG 0xF6 #define BMP085_LSB_REG 0xF7 #define BMP085_CONV_REG_XLSB 0xF8 /* prototypes */ // bmp085 void bmp085_cal(void); unsigned int bmp085_ut(void); unsigned long bmp085_up(void); void get_bmp085(void); // iic void iic_init(void); void iic_tx_init(void); void iic_rx_init(void); void start_TX(void); void start_RX(void); int sendByte_getBytes(unsigned char reg_2_read, int bytes_to_rx); //uart void TXString( char* string, int length ); /* variables */ // bmp085 // cal data int ac1; int ac2; int ac3; unsigned int ac4; unsigned int ac5; unsigned int ac6; int b1; int b2; int mb; int mc; int md; // true temp long ut; long x1; long x2; long b5; int bmp_temp = 0; //true pressure long up; long x3; long b3; unsigned long b4; long b6; unsigned long b7; long p; long bmp_pres = 0; // adjusters long b6Temp; long x1Temp; //unsigned int i; unsigned char temp_buffer[8]; unsigned char pres_buffer[8]; // tx constants const unsigned char utTxData[] = { BMP085_CTRL_REG, BMP085_TEMP_REG }; // uncomp temp reg const unsigned char upTxData[] = { BMP085_CTRL_REG, BMP085_PRESSURE_REG }; // oss =0 see bmp085.h const unsigned char msbData[] = { BMP085_MSB_REG }; // iic unsigned char *PTxData; // Pointer to TX data unsigned char TXByteCtr; unsigned char *PRxData; // Pointer to RX data unsigned char RXByteCtr; volatile unsigned char RxBuffer[3]; // Allocate 3 byte of RAM void main(void) { CSL_init(); // Activate Grace-generated configuration __enable_interrupt(); // Set global interrupt enable bmp085_cal(); // load calibration data get_bmp085(); // loop to collect temp & pressure // and TX via UART } // store PROM data into usable variables void bmp085_cal(void) { ac1 = sendByte_getBytes(0xAA, 2); __delay_cycles(1000); ac2 = sendByte_getBytes(0xAC, 2); __delay_cycles(1000); ac3 = sendByte_getBytes(0xAE, 2); __delay_cycles(1000); ac4 = sendByte_getBytes(0xB0, 2); __delay_cycles(1000); ac5 = sendByte_getBytes(0xB2, 2); __delay_cycles(1000); ac6 = sendByte_getBytes(0xB4, 2); __delay_cycles(1000); b1 = sendByte_getBytes(0xB6, 2); __delay_cycles(1000); b2 = sendByte_getBytes(0xB8, 2); __delay_cycles(1000); mb = sendByte_getBytes(0xBA, 2); __delay_cycles(1000); mc = sendByte_getBytes(0xBC, 2); __delay_cycles(1000); md = sendByte_getBytes(0xBE, 2); __delay_cycles(1000); } // read uncompensated temperature and return msb & lsb unsigned int bmp085_ut(void) { iic_tx_init(); __delay_cycles(1000); PTxData = (unsigned char *)utTxData; // send control reg and temp reg TXByteCtr = 2; // Load TX byte counter start_TX(); __delay_cycles(200000); // long delay here or it hangs on the valueline mcus return (sendByte_getBytes(BMP085_MSB_REG, 2)); } // read uncompensated pressure and return msb, lsb & xlsb unsigned long bmp085_up(void) { iic_tx_init(); __delay_cycles(1000); PTxData = (unsigned char *)upTxData; // send control reg and temp reg TXByteCtr = 2; // Load TX byte counter start_TX(); __delay_cycles(200000); // long delay here or it hangs on the valueline mcus PTxData = (unsigned char *)msbData; // send msb read register TXByteCtr = 1; start_TX(); iic_rx_init(); // set RX interrupt __delay_cycles(200000); // long delay here or it hangs on the valueline mcus PRxData = (unsigned char *)RxBuffer; // rx buffer RXByteCtr = 3; // number of bytes to receive start_RX(); // returning longs instead of ints to allow 2^16 shifts // sendByte_getBytes not used here due to long shifts return ( (( (long)RxBuffer[0] << 16) | ( (long)RxBuffer[1] << 8) | (long)RxBuffer[2]) >> 8); } // collect uncompensated temp and pressure // calculate compensated temp and pressure then transmit via UART void get_bmp085() { while (1){ ut = bmp085_ut(); up = bmp085_up(); // calc true temp x1 = ((long)ut - ac6) * ac5 >> 15; x2 = ((long)mc << 11) / (x1 + md); b5 = x1 + x2; bmp_temp = (b5 + 8) >> 4; // itoa function added itoa(bmp_temp, (char*)temp_buffer); // move integer into char buffer // calc true pressure b6 = b5 - 4000; //x1 = (b2 * (b6 * b6) >> 12) >> 11; // won't work this way on the value line LSR_23 error b6Temp = b6 * b6; x1Temp = b2 * b6Temp; x1Temp = x1Temp >> 12; x1 = x1Temp >> 11; x2 = (ac2 * b6) >> 11; x3 = x1 + x2; b3 = ((long)ac1 * 4 + x3 + 2) >> 2; // ???? so many 'corrections' on the web this one works though x1 = ac3 * b6 >> 13; x2 = (b1 * ((b6 * b6) >> 12)) >> 16; x3 = ((x1 + x2) + 2) >> 2; b4 = (ac4 * (unsigned long)(x3 + 32768)) >> 15; b7 = ((unsigned long)up - b3) * 50000; if (b7 < 0x80000000) { p = (b7 * 2) / b4;} else {p = (b7 / b4) *2;} x1 = (p >> 8) * (p >> 8); x1 = (x1 * 3038) >> 16; x2 = (-7357 * p) >> 16; bmp_pres = p + ((x1 + x2 + 3791) >> 4); // ltoa part of stdlib.h ltoa(bmp_pres, (char*)pres_buffer); TXString((char*)temp_buffer, sizeof temp_buffer); TXString("\r\n", 2); TXString((char*)pres_buffer, sizeof pres_buffer); TXString("\r\n", 2); __delay_cycles(500000); } } void iic_tx_init() { UCB0I2CSA = BMP085_ADDR; UCB0I2CIE |= UCB0TXIE; // Enable TX interrupt } void iic_rx_init(void) { UCB0I2CIE |= UCB0RXIE; // enable RX interrupt } // send 1 byte, return 2 bytes - needs the return expanded for X bytes int sendByte_getBytes(unsigned char reg_2_read, int bytes_to_rx) { // transmit slave address and register to read iic_tx_init(); __delay_cycles(1000); PTxData = (unsigned char *)®_2_read; // TX array start address TXByteCtr = sizeof reg_2_read; // Load TX byte counter start_TX(); // // receive requested bytes iic_rx_init(); // set RX interrupt __delay_cycles(1000); PRxData = (unsigned char *)RxBuffer; // rx buffer RXByteCtr = bytes_to_rx; // number of bytes to receive start_RX(); // return ((int)RxBuffer[0] << 8) | (int)RxBuffer[1]; // currently only returning 2 bytes } // iic start transmitting void start_TX(void) { UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts __no_operation(); // Remain in LPM0 until all data // is TX'd while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent } // iic restart and receive void start_RX(void) { while (UCB0CTL1 & UCTXSTP); // wait for stop UCB0CTL1 &= ~UCTR; // restart, set as receiver UCB0CTL1 |= UCTXSTT; // start condition __bis_SR_register(LPM0_bits + GIE); while (UCB0CTL1 & UCTXSTP); } // interrupt pragma is defined in grace void iic_TX_isr(void) { if (TXByteCtr) // Check TX byte counter { UCB0TXBUF = *PTxData++; // Load TX buffer TXByteCtr--; // Decrement TX byte counter } else { UCB0CTL1 |= UCTXSTP; // I2C stop condition IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX int flag } } // interrupt pragma is defined in grace void iic_RX_isr(void) { RXByteCtr--; // Decrement RX byte counter if (RXByteCtr) { P1OUT ^= 0x10; *PRxData++ = UCB0RXBUF; // Move RX data to address PRxData if (RXByteCtr == 1) // Only one byte left? UCB0CTL1 |= UCTXSTP; // Generate I2C stop condition } else { *PRxData = UCB0RXBUF; // Move final RX data to PRxData } } // tx function borrowed from TI's virtual_com_cmds.c void TXString( char* string, int length ) { int pointer; for( pointer = 0; pointer < length; pointer++) { volatile int i; UCA0TXBUF = string[pointer]; while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready? } } // timer A isr is simply toggling activity light for now. // future pwm functions to go here void timer_A_ISR(void) { P1OUT ^= BIT0; }
-
pfactorial got a reaction from dacoffey in Binary Clock
The PCB came!
But now I have to figure out how to make an enclosure for it.
Cardstock?
Any suggestions?
-
pfactorial got a reaction from bluehash in Binary Clock
The PCB came!
But now I have to figure out how to make an enclosure for it.
Cardstock?
Any suggestions?
-
pfactorial got a reaction from gatImmusepete in Fry's?
Eh. The Fry's I went to wasn't that great. They had lots of computer and software and books, etc, but I couldn't find a good selection of components and when I asked for a thermistor, they showed me a thermometer/thermostat aisle.
-
pfactorial got a reaction from nuetron in Blue 16x2 Character display - $3.98 Shipped
Ebay item 140649116679
$2.98, 16x2 LCD
I bought one and it came yesterday, and it's about the same as the other one...only one dollar cheaper
-
-
pfactorial got a reaction from Rickta59 in How to get more IO pins
#include "msp430g2211.h" char interruptcounter = 0; void main (void) { WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES; IE1 = NMIIE; P1DIR = BIT6; P1OUT = 0; __bis_SR_register(GIE); for(; {interruptcounter = 0; IE1 = NMIIE;} } #pragma vector = NMI_VECTOR __interrupt void nmistuff (void) { if (interruptcounter == 0){ P1OUT ^= BIT6; interruptcounter = 1; IFG1 = ~NMIIFG;} __bis_SR_register_on_exit(GIE); }
Debouncing is bad
-
pfactorial reacted to turd in A simple binary clock
Here's a booster pack that I made for fun. I've also used it as a POV
The watch crystal is installed on the LaunchPad.
This only works with blue or white (or similar) LEDs. To use red LEDs the voltage should be lower.
mspgcc
#include #include int seconds; int minutes; int hours; void main(void) { WDTCTL = WDTPW + WDTHOLD; //Watchdog timer on hold P1REN |= (BIT7 + BIT6); //Enable pull-up/pull-down resistors CCTL0 = CCIE; //CCR0 interrupt enabled CCR0 = 32767; //Interrupt every second TACTL = TASSEL_1 + MC_1; //ACLK, upmode WRITE_SR(GIE); //Enable global interrupts int i = 0; //Used for delays while(1) { P1DIR = minutes; //Bit pattern of minutes to output P1OUT = 0; //Bring all outputs low to light right LEDS for(i = 0; i < 1000; i++) //Delay long enough to stop left LEDS from glowing { } P1DIR = hours; //Bit pattern of minutes to output P1OUT = 31; //Bring all outputs high to light left LEDS for(i = 0; i < 1000; i++) //Delay long enough to stop right LEDS from glowing { } if ((P1IN & BIT7) == 128) //See if button one is pressed { minutes += 1; //Increment minutes } if ((P1IN & BIT6) == 64) //See if button two is pressed { hours += 1; //Increment hours } while((P1IN & BIT7) == 128) //Hold here if button one is pressed { } while((P1IN & BIT6) == 64) //Hold here if button two is pressed { } } } interrupt(TIMERA0_VECTOR) TIMERA0_ISR(void) { seconds += 1; //Increment seconds if(seconds > 59) { seconds = 0; //Reset seconds minutes += 1; //Increment minutes } if(minutes > 59) { minutes = 0; //Reset minutes hours += 1; //Increment hours } if(hours > 23) { hours = 0; //Reset hours } }
-
pfactorial reacted to turd in A simple binary clock
Thanks!
The LEDs are paired up in series so 3.5v isn't enough to make all the blue LEDs glow at once.Yep, the buttons set the time(incrementing hour/minutes).
I saw that. I can't believe how small you managed to make it!
I made it that way just because. I figured I'd end up needing it yet.
Yep, you got it
The internal pull-up/pull-down resistors are enabled with this: P1REN |= (BIT7 + BIT6);
And P1OUT = 0; and P1OUT = 31; always sets the two msb low to enable the pull-down resistors.
-
pfactorial got a reaction from turd in Binary Clock
Hello,
I made a binary clock for the MSP430G2211
I'm pretty sure I saw another binary clock but I made one myself, since the other one was a bit too big.
It shows the seconds, hours, and minutes. Unfortunately, I didn't have enough pins to add a button for time setting, unless you remove the setting function. So I just set the time before I compile the program (change the variables of hour, minutes, seconds)
I used the watchdog timer to calibrate the clock.
CODE:
#include "msp430g2211.h" unsigned int seconds = 30; unsigned int minutes = 11; unsigned int hours = 10; unsigned int variable = 0; unsigned char nmicounter = 0; void secondsdisplay1 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x01; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 1) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } secondnumber = 0; } void secondsdisplay2 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x02; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 2) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } secondnumber = 0; } void secondsdisplay3 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x04; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 4) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } secondnumber = 0; } void secondsdisplay4 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x08; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 8) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } secondnumber = 0; } void secondsdisplay5 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x10; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 16) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } secondnumber = 0; } void secondsdisplay6 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x20; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 32) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } secondnumber = 0; } void minutesdisplay1 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x01; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 1) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } minutenumber = 0; } void minutesdisplay2 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x02; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 2) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } minutenumber = 0; } void minutesdisplay3 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x04; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 4) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } minutenumber = 0; } void minutesdisplay4 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x08; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 8) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } minutenumber = 0; } void minutesdisplay5 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x10; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 16) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } minutenumber = 0; } void minutesdisplay6 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x20; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 32) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } minutenumber = 0; } void hoursdisplay1 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x01; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 1) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } hournumber = 0; } void hoursdisplay2 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x02; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 2) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } hournumber = 0; } void hoursdisplay3 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x04; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 4) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } hournumber = 0; } void hoursdisplay4 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x08; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 8) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } hournumber = 0; } void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDT_ADLY_1000 + WDTNMI + WDTNMIES; IE1 = WDTIE + NMIIE; P1DIR = 0XFF; P1OUT = 0; __bis_SR_register(GIE); for(; { minutesdisplay1(minutes); minutesdisplay2(minutes); minutesdisplay3(minutes); minutesdisplay4(minutes); minutesdisplay5(minutes); minutesdisplay6(minutes); hoursdisplay1(hours); hoursdisplay2(hours); hoursdisplay3(hours); hoursdisplay4(hours); secondsdisplay1(seconds); secondsdisplay2(seconds); secondsdisplay3(seconds); secondsdisplay4(seconds); secondsdisplay5(seconds); secondsdisplay6(seconds); IE1 = WDTIE + NMIIE; nmicounter = 0;} } #pragma vector = WDT_VECTOR __interrupt void wdtinterrupt1 (void) { seconds++; if (seconds == 60) { seconds = 0; minutes++; } if (minutes >= 60) { minutes = 0; hours++; } if (hours == 13) hours = 1; __bis_SR_register_on_exit(GIE); } #pragma vector = NMI_VECTOR __interrupt void nmiinterrupt1 (void) { if (nmicounter == 0){ minutes++; nmicounter = 1;} IFG1 &= ~NMIIFG; __bis_SR_register_on_exit(GIE); }
SCHEMATIC:
And a PCB that I made is attached as a gerber file. It is 5cmx2.5cm Since two 50mm x 25mm PCBs can fit on a 50mmx50mm square, it's twenty PCBs for ten bucks at iTead. I don't know what I'm going to do with 20 clocks though. Does anyone want a PCB? I have no need for twenty of them, but that's the cheapest price I could find.
BOTTOM:
TOP:
PLACEMENT:
BTW that's a 1.5 kohm resistor. Don't know why it doesn't show...
debouncing is still a problem.
And this concludes my first project on 43oh.
EDIT: Added reset pin function
BINARYCLOCK.zip
-
pfactorial reacted to nuetron in Binary Clock
You know, you can use the reset pin as an interrupt, instead of reset.
Check page 34 of [tipdf]slau144h[/tipdf]
-
pfactorial got a reaction from oPossum in Binary Clock
Hello,
I made a binary clock for the MSP430G2211
I'm pretty sure I saw another binary clock but I made one myself, since the other one was a bit too big.
It shows the seconds, hours, and minutes. Unfortunately, I didn't have enough pins to add a button for time setting, unless you remove the setting function. So I just set the time before I compile the program (change the variables of hour, minutes, seconds)
I used the watchdog timer to calibrate the clock.
CODE:
#include "msp430g2211.h" unsigned int seconds = 30; unsigned int minutes = 11; unsigned int hours = 10; unsigned int variable = 0; unsigned char nmicounter = 0; void secondsdisplay1 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x01; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 1) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } secondnumber = 0; } void secondsdisplay2 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x02; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 2) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } secondnumber = 0; } void secondsdisplay3 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x04; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 4) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } secondnumber = 0; } void secondsdisplay4 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x08; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 8) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } secondnumber = 0; } void secondsdisplay5 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x10; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 16) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } secondnumber = 0; } void secondsdisplay6 (unsigned int secondnumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = secondnumber & 0x20; P1OUT |= BIT7 + BIT6 + BIT5; P1OUT &= ~BIT4; if (variable == 32) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } secondnumber = 0; } void minutesdisplay1 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x01; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 1) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } minutenumber = 0; } void minutesdisplay2 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x02; P1OUT |= BIT7 + BIT6 + BIT4; P1OUT &= ~BIT5; if (variable == 2) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } minutenumber = 0; } void minutesdisplay3 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x04; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 4) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } minutenumber = 0; } void minutesdisplay4 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x08; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 8) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } minutenumber = 0; } void minutesdisplay5 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x10; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 16) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } minutenumber = 0; } void minutesdisplay6 (unsigned int minutenumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = minutenumber & 0x20; P1OUT |= BIT5 + BIT6+ BIT4; P1OUT &= ~BIT7; if (variable == 32) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } minutenumber = 0; } void hoursdisplay1 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x01; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 1) { P1OUT |= BIT3; } if (variable == 0) { P1OUT &= ~BIT3; } hournumber = 0; } void hoursdisplay2 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x02; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 2) { P1OUT |= BIT2; } if (variable == 0) { P1OUT &= ~BIT2; } hournumber = 0; } void hoursdisplay3 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x04; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 4) { P1OUT |= BIT1; } if (variable == 0) { P1OUT &= ~BIT1; } hournumber = 0; } void hoursdisplay4 (unsigned int hournumber) { P1OUT = BIT5+BIT6+BIT7+BIT4; variable = hournumber & 0x08; P1OUT |= BIT7 + BIT5+ BIT4; P1OUT &= ~BIT6; if (variable == 8) { P1OUT |= BIT0; } if (variable == 0) { P1OUT &= ~BIT0; } hournumber = 0; } void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDT_ADLY_1000 + WDTNMI + WDTNMIES; IE1 = WDTIE + NMIIE; P1DIR = 0XFF; P1OUT = 0; __bis_SR_register(GIE); for(; { minutesdisplay1(minutes); minutesdisplay2(minutes); minutesdisplay3(minutes); minutesdisplay4(minutes); minutesdisplay5(minutes); minutesdisplay6(minutes); hoursdisplay1(hours); hoursdisplay2(hours); hoursdisplay3(hours); hoursdisplay4(hours); secondsdisplay1(seconds); secondsdisplay2(seconds); secondsdisplay3(seconds); secondsdisplay4(seconds); secondsdisplay5(seconds); secondsdisplay6(seconds); IE1 = WDTIE + NMIIE; nmicounter = 0;} } #pragma vector = WDT_VECTOR __interrupt void wdtinterrupt1 (void) { seconds++; if (seconds == 60) { seconds = 0; minutes++; } if (minutes >= 60) { minutes = 0; hours++; } if (hours == 13) hours = 1; __bis_SR_register_on_exit(GIE); } #pragma vector = NMI_VECTOR __interrupt void nmiinterrupt1 (void) { if (nmicounter == 0){ minutes++; nmicounter = 1;} IFG1 &= ~NMIIFG; __bis_SR_register_on_exit(GIE); }
SCHEMATIC:
And a PCB that I made is attached as a gerber file. It is 5cmx2.5cm Since two 50mm x 25mm PCBs can fit on a 50mmx50mm square, it's twenty PCBs for ten bucks at iTead. I don't know what I'm going to do with 20 clocks though. Does anyone want a PCB? I have no need for twenty of them, but that's the cheapest price I could find.
BOTTOM:
TOP:
PLACEMENT:
BTW that's a 1.5 kohm resistor. Don't know why it doesn't show...
debouncing is still a problem.
And this concludes my first project on 43oh.
EDIT: Added reset pin function
BINARYCLOCK.zip
-
pfactorial reacted to displacedtexan in One last BMP085 Project...
GWD,
Thanks for the post and files.
I am a noob and tried to do something similar with the BMP085 and MSP430G2231 when the launchpad was released and never could get I2C to work correctly. Given the flash limitations of that chip, not sure it would have been possible...
Your work inspired me to update ccs, install grace, and get it working! BTW, for any other noobs reading this, you will need to attach pullup resistors to SCL & SDA, jumper the TXD and RXD pins since they seem reversed on the 2553, and remove the jumper for pin 1.6 that connects it to the Launchpads LED2.
Grace seems nice. It is very easy for a noob to get stuck configuring pins, clocks, etc. It was nice to refer back to see what speed you had the UART running at, the pinout for SCL/SDA, etc.
Great stuff!
Thanks again...
-
pfactorial reacted to bluehash in Hi
Well, welcome again. Sorry about this.
For your own good. For your own good.
If you had registered a year ago, you would have seen porn links plastered all over the forum, until me or GeekDoc woke up the next day to clear them out. Since the Hammer was installed 6 months back, there has been 1-4 spam links in total. Hammered accounts need to be deleted to be reactivated again. These accounts have 0 posts. That's the system, sorry. Just clarifying, since I get alot of hatemail every other day asking why they got banned.
-
pfactorial reacted to rfusca in ANnoyATron
I just completed a msp430G2001 'Annoyatron'. Great fun Was a little tougher fitting some of the code into half a kilobyte of flash though.
*Love* the hiding it in a pen idea.