Jump to content
43oh

larsie

Members
  • Content Count

    297
  • Joined

  • Last visited

  • Days Won

    7

Reputation Activity

  1. Like
    larsie got a reaction from sirri in [Energia Library] Petit FatFS SD Card Library   
    Would the larger FatFS work on larger MSP430s? Like the F5510, with 4096 KB RAM?
  2. Like
    larsie got a reaction from bluehash in LCD and Touch booster pack   
    Try this one. Should work on CCS with Touch. One of the main files just prints the cap-touch-reading on the lcd (good for debugging, in case you want to put the board inside a box or otherwise want to change the sensitivity). The other prints some text depending on the button pressed. 
     
    LarsLCD-CCS-Touch.zip
  3. Like
    larsie got a reaction from bluehash in LCD and Touch booster pack   
    Sorry, I didn't realize my message box was full. Sorry. I think I might have some code for touch on CCS, but it's a bit tangled with another project, so need to clean it up. It might take some days for me to fix. If you want to try, the key to get it working is to use the Resource explorer to create an example project for touch, and then edit the configuration files and then insert the LCD library into the same project. 
  4. Like
    larsie got a reaction from SirPatrick in Garage door opener   
    I'm trying to make a garage door opener using some cheap CC2500 boards bought through a group-buy at 43oh.com (2 USD each) and a really nice board designed by RobG. I've made a prototype first, and it seems to work, but is not very pretty. I need to maybe make it more compact and make a case for it. Here's a picture:



    The code is definitely not finished, but you can download it here if you want to look at it. It's based on the TI CC2500 library (not SimpliciTI, which would probably have been a natural choice). I'm using the bitbanging version, as I didn't have any surface mount MSP430G2553.

    I guess maybe I should put the battery beneath.
  5. Like
    larsie reacted to calinp in [Energia Library] Petit FatFS SD Card Library   
    Hello,
     
    This is a port of ChaN Petit FatFS SD library targeted to low RAM microcontrollers and offers a minimal FAT implementation, with limited write support. For more details see http://elm-chan.org/fsw/ff/00index_p.html
     
    A lot of credits goes to the main contributors to this topic http://forum.43oh.com/topic/1427-petitefs-fatfs-sdcard-usci-code/
     
     
    Because this library makes use of the SPI library included in Energia it  works for both MSP430 and Stellaris launchpads.
     
    With MSP430 I noticed some interference with Serial.print so before every call to the fat library I had to add a small delay. On Stellaris board these are not necessary. 
     
     
    Unzip and copy in Energia\hardware\msp430\libraries or Energia\hardware\lm4f\libraries .
     
    [uPDATE] See post #15 http://forum.43oh.com/topic/3209-energia-library-petit-fatfs-sd-card-library/#entry30031
     
    [DOWNLOAD LINK] http://forum.43oh.com/index.php?app=core&module=attach&section=attach&attach_id=3019
  6. Like
    larsie reacted to Rickta59 in PetiteFS FATfs SDCard USCI code   
    I went ahead and tested the booster pack and added the write support in the attached zip file. You should take a look at the Petit FatFS documentation regarding the write limitations. PetiteFS only supports writing to preexisting files and you can't grow or shrink the size of the file.
     
    For the example code to work, create a file called 'write.txt' on your sdcard. The example writes 100 lines of quick brown fox type text to the file. At the command prompt type
     
    > di
    > fi
    > fl
     
    Make sure you can see the file 'WRITE.TXT' in the listing. To write to the file type:
     
    > fw
     
    To see if it worked type:
     
    > fo WRITE.TXT
    > ft
     
    You should see numbered lines of quick brown fox...
     
    -rick
    SDCARD_PetiteFS_2553_v0.02.zip
  7. Like
    larsie got a reaction from jsolarski in Is msp430f2274 an ok chip?   
    I realized I have an F2274 already, since I've got a few of the ezmsp2500 boards around. So I tested it (set it up using Grace), and it definitely has 16 x amplification feeding into the ADC. The gain is configurable (up to 16) and which ADC it feeds into is configurable. I got max reading on the adc at about 250mV with that board. Thanks for the help. I might still go for the external op-amp, but it's good to know about this. 
     
    Edit: The op-amp can also feed to an external pin, so you can use it for other things than the ADC also. 
  8. Like
    larsie reacted to pabigot in Is msp430f2274 an ok chip?   
    Below are the only MSP430 chips that have the OpAmp peripheral (extracted from the msp430mcu metadata from TI).  Since the 2274 is the basis of the RF2500T experimenter board for the CC2500, and is also used by Anaren for similar boards, the chip gets a lot of use from folks who use that reference design.
     
    The 2274 is a fine chip, though I do wish people would stop using its XIN/XOUT lines for RF GDO pins: like the value line, the factory-configured DCO rates are way off (~10%), and the inability to calibrate in-system can cause issues if you want time measurement to have any relation to the real world.
     
    I don't have any experience using the opamp capability of the MSP430; the one application I've worked with that needed both used an external opamp because that's what the designer was familiar with.  That might turn out to be a better path for you as well.
     
    msp430f2234
    msp430f2254
    msp430f2274
    msp430fg4250
    msp430fg4260
    msp430fg4270
    msp430fg477
    msp430fg478
    msp430fg479
    msp430cg4616
    msp430cg4617
    msp430cg4618
    msp430cg4619
    msp430fg437
    msp430fg438
    msp430fg439
    msp430fg4616
    msp430fg4617
    msp430fg4618
    msp430fg4619
     
  9. Like
    larsie got a reaction from Oscarasimov in How to connect a thermistor to my MSP430 and other ?'s   
    And on the msp430, the pins can have different functions. So the code sets this pin to act as an analog input. The analog input becomes a number from 0 to 1024 (depends on the resolution of the analog to digital concerter). You can read the same voltage with a normal multimeter. The code then uses an algorithm to translate that number on that pin to the actual temperature. The algorithm is borrowed from reprap code.
     
    Energia can be a good tool to start playing with, but you can't run that code from the post directly. It will let you read analog values with less code than proper C.
  10. Like
    larsie reacted to gwdeveloper in Emmoco Bluetooth Low Energy BoosterPacks EDB-BT and EDB-BLE   
    I have the Emmoco kit. It works very well. I created a CCS project for the Stellaris LP using their API; one is included for several mcu/compiler options. Not sure what the license is but I'm only using it to tinker, for now.

    Using their em-hub is pretty easy. Software is really easy to find; no chasing links, registering for each piece of software or having to wait for codes. Information is really abundant once you're logged in. I don't think you get to see the goodies until you get a reg code in the box's lid.

    The device needed a firmware update right away but since the kit included a usb-ftdi, it only took a few minutes to download and update. The kit also contained a level shifter board for different mcu voltages. A connector cable was provided for use with boards other than the Msp430 Launchpad v1.5.

    I'm using their em-builder to create the required schemas. It's capable of building and debugging to the msp430 via GCC. I ran the demo and tested the msp430 stuff, it worked well so I moved over to the more exciting Stellaris LP. Since I'm more familiar with CCS, I'm using it to compile my applications.

    The free demo apps on the App Store are simple and to the point. I'm currently using their em-browser to check data transfers from the LP's ADC. The only issue I've run into is compiling an iOS project. It's a fresh install of Xcode on the wife's new iMac. Only tested that today and it wouldn't compile a new project, the errors were Emmoco related but I'm not faulting them. (yet?) Didn't look too much into it for lack of time but can report back later. When you make sure to follow the directions and not miss a step, the project compiles with no issues. Hoping to make my first iOS app a color wheel for changing the RGB on the Stellaris LP.

    iOS project compiling aside, I can't say enough good things about the Emmoco kit. Very easy to follow tutorials, quick to launch API and a well equipped hardware bundle makes it a winner for me. Next, I'd like to connect it to the ipad using techbasic.

    No, I'm no being compensated for this but yes, I did receive a free kit.
  11. Like
    larsie reacted to bluehash in SD card and Stellaris Launchpad   
    You can. Elm-Chan fatfs supports FAT32
  12. Like
    larsie reacted to Emeryth in USB mass storage bootloader   
    Hi,
     
    I wanted to share a bootloader I wrote for the Stellaris Launchpad (and other boards/chips if you change it up a bit).
    The bootloader acts as a mass storage device, and allows for software update by simply moving a file to the device. No software or drivers needed!
    It's inspired by the bootloader found on some NXP LPC microcontrollers.
     
    The project was surprisingly easy thanks to the awesome Stellaris USB Library.
     
    Grab the source here: https://github.com/Emeryth/Stellaris-mass-storage-bootloader
     
    Pleas report any issues you encounter.
     
  13. Like
    larsie reacted to bluehash in Stellaris Launchpad GCC Template   
    Wollw/Github.
    A simple template project for the Stellaris LaunchPad using GCC and lm4flash.
     
     
     
  14. Like
    larsie reacted to Nytblade in Emmoco Bluetooth Low Energy BoosterPacks EDB-BT and EDB-BLE   
    I haven't used that one.
     
    The Nordic nrf8001 is an easy to use one that doesn't require a software stack.  Their development kit is expensive though.
     
    The hard part to me is the "master" end of the bluetooth connection, not the slave.  TI has an open source bluetooth master library (I forget what it is called - one of their bluetooth stacks).  However, I think the standard way of operation is that a computer or phone is the master, rather than another microcontroller being the master, which is what I was trying to do in my project.  I wanted to have a higher-end MSP430 master controlling a bunch of dumb slaves in a home automation system using BLE.
     
    The Bluetooth LE spec is insane... 2300 pages in the Core Spec.  Of course you don't have to understand all that... but I like to know what I'm doing.
     
    TI has some chips that require a "binary blob" bluetooth library... like on the MetaWatch.  I strongly prefer open source - you have to watch out for those.
  15. Like
    larsie reacted to SugarAddict in Eagle Library for Stellaris LaunchPad   
    The guy is kinda annoying, but he has a bunch of tutorial videos for Eagle that are worth watching.  Here's the one relevant to this here...

  16. Like
    larsie reacted to Fred in Eagle Library for Stellaris LaunchPad   
    Attached is my Eagle Library for the Stellaris LaunchPad. It's my first attempt at creating an Eagle library so any advice would be gratefully received, but go easy on me! It was created in Eagle 6.2 so may not be compatible with earlier versions. It's heavily based on Gordon's MSP430 booster pack library from 43oh - http://forum.43oh.co...gle-footprints/
     
    I intend to use to for mounting the launchpad on a larger PCB using the female header on the bottom but it should be OK for booster packs too. I've not used it on a board yet so there's a reasonable chance I've made a mistake somewhere and not noticed yet. Please check thoroughly before using it.
    StellarisLaunchPad_Fred.lbr
  17. Like
    larsie got a reaction from RobG in Square wave generator   
    I've coded a very simple square wave generator. It uses the buttons on P1.0 eh... ooopps... PB5 and PB0 (the two first buttons on the LarsLCD board), and prints the kHz value on the LarsLCD. It should run without the LCD also. The output is on PA2 (bottom right).


    The LCD library is from CorB's post and is mainly his code by now. The generator code is adapted from the example timer code in the project documentation. If you have input on ways to write it better (button presses etc), I'm very happy to receive feedback.
     
    #include <stdint.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "glcd_hwSPI.h" void PortBIntHandler(void); #define SSI_CLK GPIO_PIN_4 #define SSI_TX GPIO_PIN_7 #define GPIO_PB4_SSI2CLK 0x00011002 #define GPIO_PB7_SSI2TX 0x00011C02 volatile int btn1 = 0; int main(void) { unsigned long ulPeriod; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // CS ENABLE GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_5); // CS LOW GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE, SSI_CLK | SSI_TX); // // Configure SSI2 // SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 2, 16); // // Enable the SSI module. // SSIEnable(SSI2_BASE); LCD_Init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 1000) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // Set up IO GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); writeString(0, 0, "Signal generator"); int f = 1; while (1) { int pressed = 0; if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_1); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f -= 1; pressed = 1; } else if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_0)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_2); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f += 1; pressed = 1; } if (pressed) { if (f < 0) { f = 1; } else if (f > 999) { f = 999; } ulPeriod = (SysCtlClockGet() / (f * 1000)) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); } setcharmode(1); writeInt(20, 2, f, 1); setcharmode(0); writeString(70, 3, "kHz"); writeString(0, 7, " - + "); pressed = 0; } } void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if (GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0); } else { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2); } }   
    Files are attached, including the LCD library. I've adapted it to use header-files.
    sq-wav-gen.zip

  18. Like
    larsie got a reaction from Thomas1426459898 in Square wave generator   
    I've coded a very simple square wave generator. It uses the buttons on P1.0 eh... ooopps... PB5 and PB0 (the two first buttons on the LarsLCD board), and prints the kHz value on the LarsLCD. It should run without the LCD also. The output is on PA2 (bottom right).


    The LCD library is from CorB's post and is mainly his code by now. The generator code is adapted from the example timer code in the project documentation. If you have input on ways to write it better (button presses etc), I'm very happy to receive feedback.
     
    #include <stdint.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "glcd_hwSPI.h" void PortBIntHandler(void); #define SSI_CLK GPIO_PIN_4 #define SSI_TX GPIO_PIN_7 #define GPIO_PB4_SSI2CLK 0x00011002 #define GPIO_PB7_SSI2TX 0x00011C02 volatile int btn1 = 0; int main(void) { unsigned long ulPeriod; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // CS ENABLE GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_5); // CS LOW GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE, SSI_CLK | SSI_TX); // // Configure SSI2 // SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 2, 16); // // Enable the SSI module. // SSIEnable(SSI2_BASE); LCD_Init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 1000) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // Set up IO GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); writeString(0, 0, "Signal generator"); int f = 1; while (1) { int pressed = 0; if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_1); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f -= 1; pressed = 1; } else if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_0)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_2); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f += 1; pressed = 1; } if (pressed) { if (f < 0) { f = 1; } else if (f > 999) { f = 999; } ulPeriod = (SysCtlClockGet() / (f * 1000)) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); } setcharmode(1); writeInt(20, 2, f, 1); setcharmode(0); writeString(70, 3, "kHz"); writeString(0, 7, " - + "); pressed = 0; } } void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if (GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0); } else { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2); } }   
    Files are attached, including the LCD library. I've adapted it to use header-files.
    sq-wav-gen.zip

  19. Like
    larsie got a reaction from CorB in Square wave generator   
    I've coded a very simple square wave generator. It uses the buttons on P1.0 eh... ooopps... PB5 and PB0 (the two first buttons on the LarsLCD board), and prints the kHz value on the LarsLCD. It should run without the LCD also. The output is on PA2 (bottom right).


    The LCD library is from CorB's post and is mainly his code by now. The generator code is adapted from the example timer code in the project documentation. If you have input on ways to write it better (button presses etc), I'm very happy to receive feedback.
     
    #include <stdint.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "glcd_hwSPI.h" void PortBIntHandler(void); #define SSI_CLK GPIO_PIN_4 #define SSI_TX GPIO_PIN_7 #define GPIO_PB4_SSI2CLK 0x00011002 #define GPIO_PB7_SSI2TX 0x00011C02 volatile int btn1 = 0; int main(void) { unsigned long ulPeriod; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // CS ENABLE GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_5); // CS LOW GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE, SSI_CLK | SSI_TX); // // Configure SSI2 // SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 2, 16); // // Enable the SSI module. // SSIEnable(SSI2_BASE); LCD_Init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 1000) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // Set up IO GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); writeString(0, 0, "Signal generator"); int f = 1; while (1) { int pressed = 0; if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_1); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f -= 1; pressed = 1; } else if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_0)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_2); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f += 1; pressed = 1; } if (pressed) { if (f < 0) { f = 1; } else if (f > 999) { f = 999; } ulPeriod = (SysCtlClockGet() / (f * 1000)) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); } setcharmode(1); writeInt(20, 2, f, 1); setcharmode(0); writeString(70, 3, "kHz"); writeString(0, 7, " - + "); pressed = 0; } } void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if (GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0); } else { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2); } }   
    Files are attached, including the LCD library. I've adapted it to use header-files.
    sq-wav-gen.zip

  20. Like
    larsie got a reaction from Automate in Square wave generator   
    I've coded a very simple square wave generator. It uses the buttons on P1.0 eh... ooopps... PB5 and PB0 (the two first buttons on the LarsLCD board), and prints the kHz value on the LarsLCD. It should run without the LCD also. The output is on PA2 (bottom right).


    The LCD library is from CorB's post and is mainly his code by now. The generator code is adapted from the example timer code in the project documentation. If you have input on ways to write it better (button presses etc), I'm very happy to receive feedback.
     
    #include <stdint.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "glcd_hwSPI.h" void PortBIntHandler(void); #define SSI_CLK GPIO_PIN_4 #define SSI_TX GPIO_PIN_7 #define GPIO_PB4_SSI2CLK 0x00011002 #define GPIO_PB7_SSI2TX 0x00011C02 volatile int btn1 = 0; int main(void) { unsigned long ulPeriod; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // CS ENABLE GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_5); // CS LOW GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE, SSI_CLK | SSI_TX); // // Configure SSI2 // SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 2, 16); // // Enable the SSI module. // SSIEnable(SSI2_BASE); LCD_Init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 1000) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // Set up IO GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); writeString(0, 0, "Signal generator"); int f = 1; while (1) { int pressed = 0; if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_1); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f -= 1; pressed = 1; } else if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_0)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_2); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f += 1; pressed = 1; } if (pressed) { if (f < 0) { f = 1; } else if (f > 999) { f = 999; } ulPeriod = (SysCtlClockGet() / (f * 1000)) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); } setcharmode(1); writeInt(20, 2, f, 1); setcharmode(0); writeString(70, 3, "kHz"); writeString(0, 7, " - + "); pressed = 0; } } void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if (GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0); } else { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2); } }   
    Files are attached, including the LCD library. I've adapted it to use header-files.
    sq-wav-gen.zip

  21. Like
    larsie got a reaction from bluehash in Square wave generator   
    I've coded a very simple square wave generator. It uses the buttons on P1.0 eh... ooopps... PB5 and PB0 (the two first buttons on the LarsLCD board), and prints the kHz value on the LarsLCD. It should run without the LCD also. The output is on PA2 (bottom right).


    The LCD library is from CorB's post and is mainly his code by now. The generator code is adapted from the example timer code in the project documentation. If you have input on ways to write it better (button presses etc), I'm very happy to receive feedback.
     
    #include <stdint.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" #include "glcd_hwSPI.h" void PortBIntHandler(void); #define SSI_CLK GPIO_PIN_4 #define SSI_TX GPIO_PIN_7 #define GPIO_PB4_SSI2CLK 0x00011002 #define GPIO_PB7_SSI2TX 0x00011C02 volatile int btn1 = 0; int main(void) { unsigned long ulPeriod; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // CS ENABLE GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_5); // CS LOW GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5, 0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE, SSI_CLK | SSI_TX); // // Configure SSI2 // SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, SysCtlClockGet() / 2, 16); // // Enable the SSI module. // SSIEnable(SSI2_BASE); LCD_Init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); ulPeriod = (SysCtlClockGet() / 1000) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // Set up IO GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); writeString(0, 0, "Signal generator"); int f = 1; while (1) { int pressed = 0; if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_1); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f -= 1; pressed = 1; } else if (!GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_0)) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_PIN_2); SysCtlDelay(1000000); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0); f += 1; pressed = 1; } if (pressed) { if (f < 0) { f = 1; } else if (f > 999) { f = 999; } ulPeriod = (SysCtlClockGet() / (f * 1000)) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); } setcharmode(1); writeInt(20, 2, f, 1); setcharmode(0); writeString(70, 3, "kHz"); writeString(0, 7, " - + "); pressed = 0; } } void Timer0IntHandler(void) { // Clear the timer interrupt TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the GPIO pin and // write back the opposite state if (GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_2)) { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0); } else { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2); } }   
    Files are attached, including the LCD library. I've adapted it to use header-files.
    sq-wav-gen.zip

  22. Like
    larsie reacted to Thomas1426459898 in SLLogicLogger - A simple logic analyser for the Stellaris Launchpad   
    Hi,
     
    Here is my last project with the Stellaris Launchpad: SLLogicLogger - A simple logic analyser for the TI Stellaris Launchpad.
     
    Logic levels on PORTB are sampled with 10MHz to RAM (16 kBytes) and then transmitted through the debugging controller over USB to a host computer. No additional hardware is needed - a pure Stellaris Launchpad connected over the debug-USB to an PC is enough. The firmware implements the main functions of SUMP, a serial protocol for logic analysers. There are some clients which supports SUMP. I used LogicSniffer OLS (http://www.lxtreme.nl/ols/) which is a multiplatform Java client. A simple OLS profile file is sufficient to read out the sampled data from the Launchpad.
    Sampling starts on any state change on PORTB, no further trigger functions are supported yet.
     
    Further description and download:
    http://www.fischl.de/arm/sllogiclogger_logic_analyser_for_stellaris_launchpad/
     
    The logic states are sampled from the GPIO to an array within an for-loop:
    // sampling buffer char buffer[BUFFERSIZE]; // aquire data for (i = BUFFERSIZE; i != 0; i--) { buffer[i - 1] = GPIO_PORTB_DATA_R; } With this method I get 10 MHz sampling rate at 80 MHz system clock. Does anybody know, if there is a chance to speed it up? E.g. using AHB, uDMA, ...?
     
    Thomas

  23. Like
    larsie reacted to hvontres in How fast is the IO?   
    What is the input capacitance for your scope probes? For fast square waves, I built one of these: http://koti.mbnet.fi/jahonen/Electronics/DIY%201k%20probe/
    For this to work, your scope needs to either have a 50 Ohm input mode or you need to use an inline 50 Ohm terminator. This will give you ~1Ghz response for only a couple of $
  24. Like
    larsie reacted to Thomas1426459898 in How fast is the IO?   
    Interesting topic! I played around with the other direction: reading fast as possible from GPIO and save the values to RAM (see project description http://forum.stellarisiti.com/topic/335-open-nov-dec-2012-stellarisiti-project-of-the-month-contest/?p=1972). I got a maximum sample rate of 10 MHz. Perhaps some of this hints are also useful for reading GPIO instead of toggling!
     
     
  25. Like
    larsie got a reaction from CorB in Search length   
    Would it be possible to allow shorter search words? I can't search for PWM for example, since it has to have four characters. 
×
×
  • Create New...