Jump to content
43oh

PTB

Members
  • Content Count

    113
  • Joined

  • Last visited

  • Days Won

    5

Reputation Activity

  1. Like
    PTB reacted to RobG in 2.2" 320x240 Color LCD Booster Pack   
    Say hello to the new member of my Color LCD Booster Pack family, 2.2" LCD with 320x240 pixel resolution.
    Current version is v3.
    Board options include backlight transistor and microSD (TransFlash) socket (v2 of the board also has optional memory 23K SRAM, 25AA EEPROM, or similar.)
    New in v3:
    - no MOSI/MISO config
    - no optional memory
    - 4 configuration jumpers CS_Display, CS_SD, D/C, and BKG (choose legacy pinout or compliant with new LPs.)
    Pos/Pin CS_Dis CS_SD D/C BKG New(1) P2.5 P2.4 P1.3 P2.0 Legacy(2) P1.0 P2.5 P1.4 P2.2 Available on Tindie and The 43oh Store
     
    Driver is in this post.
     
    UPDATE: Tiva driver is now available, see link above!
    v2

    v3

     


     
     

  2. Like
    PTB reacted to jkabat in Stellaris fast analog reads   
    @@PTB @@Rei Vilo
     
    Possible fix for fast_analog read:
     
    Replace:
    while (!(HWREG(ADC0_BASE + ADC_O_ISC) & (0x10001 << SEQUENCER))) {}
     
     
    with:
    while (!(HWREG(ADC0_BASE + ADC_O_RIS) & (0x10000 | (1 << SEQUENCE))) {}

    This MAY fix the problem! Regards
    John
  3. Like
    PTB reacted to Rei Vilo in Stellaris fast analog reads   
    In France, we use the same logic but from Le Discours de la méthode (1637) by Descartes, more precisely the second rule:  
     
     
     
     
    or in English
     
     
    One can't imagine how modern and well suited for programming Descartes precepts are
  4. Like
    PTB reacted to Rei Vilo in Stellaris fast analog reads   
    Fast_Analog_Read.cpp: In function 'uint16_t fast_analogRead()': Fast_Analog_Read.cpp:134:40: error: cannot convert 'uint16_t* {aka short unsigned int*}' to 'long unsigned int*' in initialisation @@PTB
     
    You're doing right with using the C99 types instead of the literal ones, impossible to read and use...
     
    Unfortunately, unsigned long means uint32_t and not uint16_t. Just change the value[1] definition for uint32_t value[1];
    Fast_Analog_Read.cpp:162:15: error: 'ADC_SEQ' was not declared in this scope Fast_Analog_Read.cpp:162:26: error: 'ADC_SEQ_STEP' was not declared in this scope Fast_Analog_Read.cpp:168:14: error: 'ADC_SSFSTAT' was not declared in this scope Fast_Analog_Read.cpp:172:24: error: 'ADC_SSFIFO' was not declared in this scope Those constants are in adc.c but not in adc.h, so they aren't included with the #include "driverlib/adc.h"
     
    As a solution, add those line to your sketch:
    // Constants from adc.c #define ADC_SEQ (ADC_O_SSMUX0) #define ADC_SEQ_STEP (ADC_O_SSMUX1 - ADC_O_SSMUX0) #define ADC_SSMUX (ADC_O_SSMUX0 - ADC_O_SSMUX0) #define ADC_SSEMUX (ADC_O_SSEMUX0 - ADC_O_SSMUX0) #define ADC_SSCTL (ADC_O_SSCTL0 - ADC_O_SSMUX0) #define ADC_SSFIFO (ADC_O_SSFIFO0 - ADC_O_SSMUX0) #define ADC_SSFSTAT (ADC_O_SSFSTAT0 - ADC_O_SSMUX0) #define ADC_SSOP (ADC_O_SSOP0 - ADC_O_SSMUX0) #define ADC_SSDC (ADC_O_SSDC0 - ADC_O_SSMUX0) Please find enclosed the sketch I've compiled with embedXcode and Energia successfully. 
     

     
    I couldn't test it as I don't have a StellarPad board at hand right now.
     
    LM4F_ADC.ino.zip
  5. Like
    PTB reacted to jkabat in Stellaris fast analog reads   
    @@PTB,
     
    I probably extracted it wrong.  See the original in driverlib/adc.c.   Also I should have had you include driverlib/adc.h which would have taken care of those pesky defines
     
    john
  6. Like
    PTB reacted to jkabat in Stellaris fast analog reads   
    PTB,
     
    Your problem intrigued me so i did some thinking. (In my day job optimization and speed is a way of life!)
     
    I have split out into some semi-optimized routines below. This is more or less a direct translation of analogRead in wiring.c.  IT HAS NOT BEEN TESTED but should work. (I think so)
     
     
    your routine should be:
     
    fast_analogInit(PE_3);
    for (uint16_t i=0;i<SampleQty;i++)
    {
    // Sample=analogRead(PE_3);
    //Sample[i] = GPIOPinRead(SENSOR_INT_BASE, SENSOR_INT_PIN);
    Sample = fast_analogRead();
    }
     
    for further optimization you could have the sequencer run continuously and/or place the result directly in your table.   Be careful Sequencer 3 has a FIFO depth of only one entry . Change to sequencer 0 to get a deptf of 16.
     
     
    Here is the my code:
    unsigned long faBase;uint16_t faMask;#define SEQUENCER 3uint16_t fast_analogInit(uint8_t pin) { uint8_t port = digitalPinToPort(pin); uint16_t value[1]; uint32_t channel = digitalPinToADCIn(pin); if (pin == NOT_ON_ADC) { //invalid ADC pin return(0); } faBase = (uint32_t)portBASERegister(port); faMask = digitalPinToBitMask(pin); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ROM_GPIOPinTypeADC((uint32_t)portBASERegister(port), digitalPinToBitMask(pin)); ROM_ADCSequenceConfigure(ADC0_BASE, SEQUENCER, ADC_TRIGGER_PROCESSOR, 0); ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, 0, channel | ADC_CTL_IE | ADC_CTL_END); ROM_ADCSequenceEnable(ADC0_BASE, SEQUENCER); return(1);}uint16_t fast_analogRead(void) { uint16_t value[1]; unsigned long *pulBuffer = &value[0]; unsigned long ulCount; unsigned long ulBase = faBase;// ROM_ADCIntClear(ADC0_BASE, 3);//// Clear the interrupt.// HWREG(ADC0_BASE + ADC_O_ISC) = 1 << SEQUENCER; // ROM_ADCProcessorTrigger(ADC0_BASE, 3);//// Generate a processor trigger for this sample sequence.// HWREG(ADC0_BASE + ADC_O_PSSI) |= ((SEQUENCER & 0xffff0000) | (1 << (SEQUENCER & 0xf))); // while (!ROM_ADCIntStatus(ADC0_BASE, 3, false)) {} while (!(HWREG(ADC0_BASE + ADC_O_ISC) & (0x10001 << SEQUENCER))) {}// ROM_ADCIntClear(ADC0_BASE, 3);//// Clear the interrupt.// HWREG(ADC0_BASE + ADC_O_ISC) = 1 << SEQUENCER;// ROM_ADCSequenceDataGet(ADC0_BASE, 3, (unsigned long *)value); // // Get the offset of the sequence to be read. // ulBase += ADC_SEQ + (ADC_SEQ_STEP * SEQUENCER); // // Read samples from the FIFO until it is empty. // ulCount = 0; while (!(HWREG(ulBase + ADC_SSFSTAT) & ADC_SSFSTAT0_EMPTY) && (ulCount < 8)) { // // Read the FIFO and copy it to the destination. // *pulBuffer++ = HWREG(ulBase + ADC_SSFIFO); // // Increment the count of samples read. // ulCount++; } return value[0];}
  7. Like
    PTB reacted to Rei Vilo in Stellaris fast analog reads   
    As an additional resource, I strongly recommend the really great hands-on tutorial from Texas Instruments, with text-box, workshops, videos and step-by-step guides.
     
    Find it at Getting Started with the Stellaris EK-LM4F120XL LaunchPad Workshop
     
    and especially Workshop 5: ADC12
  8. Like
    PTB reacted to jkabat in Stellaris fast analog reads   
    @Rei Vilo
     
    You need to look at the source for wiring_analog.c and driverlib\adc.c./ There is a lot of overhead that can be removed. Most routines in adc.c boild down to 1 line that can be inserted into a copy of analogRead. this will run faster and eliminate the ROM_ calls.
     
    If you are really ambitious you can move the ADC code to use sequencer 0 rather than 3. Sequencer 0 has a 16 entry fifo for readings. you can interrupt at half full to read the values. 
    As the next step use DMA instead of interrupts to directly place the values in memory.
     
    This is all off the top of my head after a quick peek at the source for the analog stuff.
     
    Have fun!
     
    John
  9. Like
    PTB reacted to nimblemotors in Tractor Engine Control   
    Hello again my friends,
    I posted the video of the full msp430 based EFI system running my tractor.
    You can see the waterproof box that holds the fuses and all the connections.
    Originally this tractor did not have a single fuse.
     

     
    The fuel injector is a TBI unit from a Geo Metro, just using the injector portion of the TB.
    The throttle plate is from a Prius, and is an electronic controlled throttle.
    Processor is a msp4301232, with two high-side mosfets (previously used to charge NiMH batterys),
    one used to control the throttle, the other controls the fuel injector. The ADC inputs from the 430 are used to read the analog sensor inputs (GM parts) the o2 sensor, the MAP, the water temp.
    The Tach input signal of course is the msp430 based coil-on-plug ignition I showed earlier.
     
    Also here is the dashboard I built for it, using msp430 processors that drive bargraphs on the LCDs
    for the readings. Fuel level, Water Temp, Battery Voltage, Oil Pressure, and RPM.
     

  10. Like
    PTB reacted to Rei Vilo in Stellaris fast analog reads   
    As @JKabat rightly said, 
     
     
    Please refer to this thread where I've explored the fast read/write operation with Energia.
     
  11. Like
    PTB got a reaction from bkb in Stellaris fast analog reads   
    Hi folks,
     
    I would like to do some pretty fast analog reads with the stellaris board. Preferably just from one pin.
     
    I loaded a snippet of code using 100 sequential reads
    .... Sample[0]=analogRead(PE_3); Sample[1]=analogRead(PE_3); Sample[2]=analogRead(PE_3); Sample[3]=analogRead(PE_3); Sample[4]=analogRead(PE_3); Sample[5]=analogRead(PE_3); Sample[6]=analogRead(PE_3); .... etc. And measured the time in microseconds at the beginning and end => and got 1434 microseconds to reel in 100 samples
    Assuming my maths is right, that's ~69,400 samples per second or one sample every 14.4 microseconds.
     
    I would love to get this down to pretty close to 1 sample every microsecond or as close as possible to it.
     
    I am doing the code in energia as this is what I am most comfortable with. I had a play with Code Composer but I have decided that is for smarter folks than me.
     
    Have found some very interesting links for the arduino for speeding up analog reads
    http://forum.arduino.cc/index.php/topic,6549.0.html
     
    Plus some other links using external ADC chips (doesn't suit me as I don't have enough spare pins, Though I could change a few things to get them if it was my only option)
    http://bobdavis321.blogspot.com.au/2013/06/arduino-powered-3-million-samples-per.html
     
    Soooo..... Are there any tricks (Energia style) you folks know of where I could squeeze a bit higher sampling rate?
     
    Its all very early days at the moment and I am just trying to sort out my plan of attack.
    Any advice or suggestions greatly appreciated.
     
    Thanks
     
    PTB (The perpetual Noob)
  12. Like
    PTB reacted to Rei Vilo in [Energia Library] LCD_screen Library Suite   
    The library for the Kentec 3.5 BoosterPack is available here
     
    The library wouldn't have been possible without the help of the forum and its members. Many thanks to them!
     
    As a colourful example, I've included a tool for drawing.
     

     
      Remember, the Kentec 3.5" BoosterPack requires a LaunchPad Stellaris.   Read my review at http://embeddedcomputing.weebly.com/kentec-35-lcd-with-touch-boosterpack-for-stellaris.html   This is a cross-post with the Stellarisiti forum.
  13. Like
    PTB reacted to Rei Vilo in [Energia Library] LCD_screen Library Suite   
    Good news! The LCD_GUI library is available and brings the usual elements of a graphic interface as: label, button, dialog box, menu, slider and text box.
     

     
    The project is based on a LaunchPad Stellaris, a HY28A touch screen and 2x 1Mb of SRAM, and should cost less than USD35. The SRAM is used as a fast cache for the screen.
     
    Learn more about the project and the LCD_GUI library   
     
  14. Like
    PTB reacted to f4dtr in Energia Cheat Sheet   
    Hi,
     
    I created a cheat-sheet for Launchpad, based on  http://www.cheat-sheets.org/#Arduino'>
  15. Like
    PTB reacted to Rei Vilo in [Energia Library] LCD_screen Library Suite   
    As of October 2015 and due to intellectual property issues and licence infringements with users, the LCD_screen Library Suite is no longer available for download.
     
    A special edition of the library is included in Energia for the Educational BoosterPack MKII and the Kentec 3.5" screen, and comes as an external library for the Pervasive Displays e-paper screens, to be installed with the Libraries Manager. 
     



    Hi!
     
    I've decided to consolidate the libraries I've developed for different screens into a single one, the LCD_screen Library Suite.

    Download with examples and documentation is available here. The library runs on the LaunchPads MSP430 and Stellaris with Energia 0009. 
     
    As at today, the following screens are supported: Color LCD Booster Pack (ST7735R) http://forum.43oh.com/topic/1758-color-lcd-booster-pack/ 2.2" Color LCD Booster Pack with Touch (ILI9225B+XPT2046) http://forum.43oh.com/topic/2574-22-color-lcd-booster-pack-with-touch/ 2.8" Touch Screen TFT LCD with SPI interface (ILI9320+XPT2046) http://www.hotmcu.com/28-touch-screen-tft-lcd-with-spi-interface-p-42.html I also leverage the high-level libraries I wrote for the 4D Systems screens, for example this clock that literally requires two lines of code:

    myClock.define(&myScreen, 160, 120, 60); myClock.draw(hour, minute, second, "Message"); Enjoy 
  16. Like
    PTB reacted to L293D in [Energia Library] LCD_screen Library Suite   
    Quick question -
     
    I see a bunch of examples in the library which is awesome, however I notice that for instance the gauge examples are asking for files which are not present in the zip file.  Am I missing something, or is the zip file missing something?
     
    Also, so far, I like the library Rei...great work!
     
     
    L293D
  17. Like
    PTB got a reaction from bluehash in The Booster BoosterPack - LiPo Battery Pack + USB Charger   
    Just a quick little update to my previous "NoobReview".
     
    Finally got the headers and time to solder them on. Plugged it in and....
     
    Look Ma... No wires.
     
     
     
    This is a Stellaris => Bluehash Booster Booster => RobG touchscreen stack.
     
    On a full charge, I just let it sit there and it ran for about 2:30 hours before it started getting dim.
    At 2:50 hours it was very dim and I tried the touchscreen, but it was by then unresponsive but you could still read the display.
     
    So that's a pretty decent run with the backlight on the whole time. I may get a bigger battery and see how long I can stretch it out.
     
    Anyway..... that's pretty much it.
     
    Cheers
    PTB

  18. Like
    PTB reacted to Rei Vilo in [Energia Library] LCD_screen Library Suite   
    Hi!
     
    I've decided to consolidate the libraries I've developed for different screens into a single one, the LCD_screen Library Suite.

    Download with examples and documentation is available here. The library runs on the LaunchPads MSP430 and Stellaris with Energia 0009. 
      As at today, the following screens are supported:
    Color LCD Booster Pack (ST7735R) http://forum.43oh.com/topic/1758-color-lcd-booster-pack/ 2.2" Color LCD Booster Pack with Touch (ILI9225B+XPT2046) http://forum.43oh.com/topic/2574-22-color-lcd-booster-pack-with-touch/ 2.8" Touch Screen TFT LCD with SPI interface (ILI9320+XPT2046) http://www.hotmcu.com/28-touch-screen-tft-lcd-with-spi-interface-p-42.html I also leverage the high-level libraries I wrote for the 4D Systems screens, for example this clock that literally requires two lines of code:

    myClock.define(&myScreen, 160, 120, 60); myClock.draw(hour, minute, second, "Message"); Enjoy
  19. Like
    PTB reacted to PentiumPC in 3D printed bumper.   
    http://www.thingiverse.com/thing:92339
     
    Just to share a simple bumper I made for MSP430 Launchpad.
     


  20. Like
    PTB reacted to RobG in Community BoosterPacks for Maker Faire Display   
    Flashy blinky display is ready  Might have to dial down couple of them
     

  21. Like
    PTB reacted to RobG in Community BoosterPacks for Maker Faire Display   
    Make sure you save some space in your suitcase for my display board
     
    Still need to secure all the boards and run power to six of them.
     

  22. Like
    PTB got a reaction from bluehash in The Booster BoosterPack - LiPo Battery Pack + USB Charger   
    Hi Bluehash,
     
    Received the board today. It looks great. Thanks Heaps.
    Here are my comments/observations in addition to what cubeberg and Jwoodrell have already said. Even though I have been playing with electronics for a little while now, please remember I do have noob like tendencies. ;-)
    Anyway...... Here we go....
     
    1. Happy to pay a little more to get stackable header pins included as there were none with it.
     
    2. As others have said it would be good to have a standard lipo connector on the board instead of the 0.1" header pins. Even better would be to have the connector as a 90 degree type so it lies flatter. This would enable full size boards to be stacked on top of it or alternatively stack the booster booster under the launchpad. This would require either moving the connector location maybe to bottom right corner or alternatively moving C2 and U1 out of the way so the connector could lay flat.
     
    3. There is plenty of empty space on the board. How about some 3mm mounting holes strategically placed out of the way. This would then also add mountability to any launchpad, assuming the booster booster was underneath.
     
    4. How about a second row of holes down each side. These wouldnt connect to anything but could be pass through header pins to make it stellaris friendly. Obviously only useful to a booster that uses the other pins.
     
    5. This last idea is probably too expensive and impractical, but here it is anyway. An input for solar cells, something like this from adafruit. http://www.adafruit.com/products/390
     
    I like where the switch is placed and that it has a long actuator. Should be able to protrude through a case.
    I have just ordered some stackable headers from ebay and will try it for real when they show up. Its currently charging and is not connected to a launchpad or booster pack. Red led on and seems to be charging ok.
     
    I'll add a bit more to this post once I give it a proper whirl.
     
    Those are all just suggestions. It's fantastic. Better than anything I could have done.
     
    Cheers
    PTB
  23. Like
    PTB reacted to PentiumPC in Motorised Slider.   
    Not 100% a MSP430 project but it is used as the stepper and camera trigger control.
     
    It is based on a cheap china made (no offense) slider, seem like a IGUS clone, quality wasn't too good but ok as a time lapse rail.
     

     
    Control was achieve thru a MSP430 Launchpad, a BT booster pack, home switch and trigger / stepper board (with easy driver) I made years ago.
     
    Other parts includes , a NEMA 17 stepper, common skate board bearing for idler, and 2GT belt, mountings are 3D printed, will make aluminium parts when I have some free time.
     

     

     

     

     
    stl for prints can be found here.
     
    http://www.thingiverse.com/thing:85274
     
    video shot with this prototype slider can be found on youtube.
     
    https://www.youtube.com/watch?feature=player_embedded&v=2OwjdrRMq2w
     
     
    Code and schematics to follow (once I have a good working version)
     
    Cheers and have fun.
     
  24. Like
    PTB reacted to kennylin0309 in 43oh Store International Shipping May Have to Stop   
    First, Sorry for my poor english.

    I am from Taiwan. Taiwan to Boston United States is 7718 miles.

    I appreciate that bluehash make awesome 43oh.com.
    I read 43oh forum every day and I learn a lot every day.

    I bought some awesome boards from 43oh store totally $278.53 USD
    There are my order history:

    1.) 15 March 2013 have not received this package "yet".
    2.) 25 March 2013 have received package in less then three weeks.
    3.) 09 April 2013 have received package in less then two weeks.
    4.) 27 April 2013 just shipped, a few days ago.

    About the first package that I have not received yet. I just waiting.
    I didn't send e-mail to bluehash.
    i don't want to ask about claim.

    The only thing I did is that I order again some boards when these awesome boards restock.

    why?

    bluehash is not digi-key / mouser.
    bluehash use his own time in order to support the 43oh.
    I learned a lot from the 43oh forum, I truly appreciate that.
    I don't want to disturb bluehash.

    The USPS package tracking system shows that package had shipped.
    Taiwan is far away from the U.S. Anything could happen.
    This is trade-off between flat rate shipping fee and increasing shipping fee include "insurance fee" to cover up lost packages.

    In my opinion..if this continues
    Stop international shipping is OK for me , I can use package forward service instead.
    or Add a option which is increasing international shipping fee include "insurance fee".
    Expensive Fedex is a good option too.

    In short, I truly appreciate that bluehash is doing good job and nothing can stop me from buying awesome boards from 43oh store.
  25. Like
    PTB reacted to cubeberg in Relay Booster   
    Here is a Relay boosterpack that I'm planning on using for a couple of things.  

     
    There are a couple of units available on Tindie.
     
    First - I built a wireless fireworks launcher last year for the 4th of july using the Anaren booster.  Unfortunately the range was much too short - so I'm hoping to use a pair of NRF24L01's.  The relays work great to trigger nichrome wire.
    Second - I'm helping a co-worker out with a home-automation project.  The relays work great as a dry-contact.  
     
    One of the reasons why I went with creating a booster was to make sure the traces were nice and large - in case I needed it to run something beefy.  Most relay boards I've found online have fairly thin traces.  I used all available space (top and bottom) to make mine as large as possible.  If you take a look at the pictures of the board - you'll see the large planes for NO/NC and COM for the relays.  I haven't tested yet - but based on a PCB trace width calculator - they should be able to take several amps.  Might be good for solenoids or really beefy motors.
     

     
    Some additional info:
    Relays are numbered on the board - Relay 1 is in the upper-left.   NO and NC are labeled next to the screw terminals - the center is common. Power for triggering the relays is provided via a two-pin header at the bottom of the board.  For testing, I've been using a 9v battery.   Latch and Enable pins are selectable via a set of small jumpers on the back.  The testing code I've provided are set for Enable - 2.2 and Latch - 2.3.  2.2 through 2.5 are available for selection for either feature. The board doesn't use opto-isolators - so only DC should be used.  
    BOM - Parts are all Tayda
    SOIC 595 Shift Register (1)
    ULN2003AD SOIC Darlington Array (1)
    ~1K Pull-up Resistor (1)
    1N4006 Rectifier diode or similar (4) - These serve as protection diodes
    Relays (4) - I used 6v relays - but the footprint fits plenty of other types of mini relays
    3 Position, 3.5mm terminal block (4)
     
     
    Eagle files are attached.  
     
    Here is a sample program for CCS.  Pushing button 1 
    #include <msp430.h> /* * main.c */ #define CS_595 BIT3 //P2 #define ENABLE BIT2 //P2 #define SCL_PIN BIT5 //CLK #define SDA_PIN BIT7 //Data to 595's #define DISABLE_SR P2DIR |= ENABLE; P2OUT |= ENABLE #define ENABLE_SR P2DIR &= ~ENABLE; P2OUT &= ~ENABLE #define SR_DESELECT P2OUT &= ~CS_595 //Select shift register #define SR_SELECT P2OUT |= CS_595 //Deselect shift register #define BUTTON BIT3 #define RELAY_1 BIT1 #define RELAY_2 BIT2 #define RELAY_3 BIT3 #define RELAY_4 BIT4 #define TEST_DELAY 5000000 //Function prototypes void initSPI(); void write(char relays); int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //configuration from GRACE BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0; if (CALBC1_16MHZ != 0xFF) { /* Adjust this accordingly to your VCC rise time */ __delay_cycles(100000); /* Follow recommended flow. First, clear all DCOx and MODx bits. Then * apply new RSELx values. Finally, apply new DCOx and MODx bit values. */ DCOCTL = 0x00; BCSCTL1 = CALBC1_16MHZ; /* Set DCO to 16MHz */ DCOCTL = CALDCO_16MHZ; } BCSCTL1 |= XT2OFF + DIVA_0; BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1; //INTERRUPT ON 1.3 - Pull up resistor enabled P1IE |= BUTTON; P1IFG |= BUTTON; P1REN |= BUTTON; P1OUT |= BUTTON; P1IFG &= ~BUTTON; P1DIR |= BIT0|BIT6; P1OUT &= ~(BIT0|BIT6); _bis_SR_register(GIE); initSPI(); ENABLE_SR; LPM0; //sleep until button press while(1) { P1OUT |= BIT0|BIT6; write(RELAY_1|RELAY_2|RELAY_3|RELAY_4);//all on _delay_cycles(8000000); //half second P1OUT ^= BIT0; write(RELAY_2|RELAY_3|RELAY_4);//turn off 1 _delay_cycles(8000000); //half second P1OUT ^= BIT0; P1OUT ^= BIT6; write(RELAY_3|RELAY_4);//turn off 2 _delay_cycles(8000000); //half second P1OUT ^= BIT0; P1OUT ^= BIT6; write(RELAY_4); //turn off 3 _delay_cycles(8000000); //half second write(0x00);//turn off all P1OUT &= ~(BIT0|BIT6); //turn off all LEDs LPM0; } } //Set up USCI_B for SPI void initSPI() { P1DIR |= SCL_PIN|SDA_PIN; P2DIR |= CS_595; SR_DESELECT; P1SEL |= SCL_PIN + SDA_PIN; P1SEL2 |= SCL_PIN + SDA_PIN; UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // div/1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // Initialize _delay_cycles(5000); } /* * Outputs relay settings to booster */ void write(char relays) { SR_SELECT; UCB0TXBUF = relays; //this will end up on the second shift register while (!(IFG2 & UCB0TXIFG)); //wait for send to complete SR_DESELECT; } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { //P1OUT ^= 0x01; // P1.0 = toggle P1IFG &= ~BUTTON; LPM0_EXIT; } RelayBP_Eagle.zip
×
×
  • Create New...