Jump to content
43oh

CorB

Members
  • Content Count

    288
  • Joined

  • Last visited

  • Days Won

    5

Reputation Activity

  1. Like
    CorB got a reaction from peawlbral in Launchpaddemo on GLCD (with scrolling graph)   
    Hi,
     
    Find attached code to run the launchpadDemo on the GLCD boosterpack(Lars Roland), The code will show the temperature in tenths of a degree and after pressing Switch2 on the GLCD boosterpack a scrolling graph will show the changes in temperature.
     
    The file called Example_F2802xLaunchPadDemo1.c can be used to replace the original launchpaddemo file. All other files should be copied into the directory where "Example_F2802xLaunchPadDemo" resides.
     
    The graph on the GLCD is is based on graphs writing to a screenmemory that can be dumped to the LCD.
     
    I will add a screenshot tomorrow (EDIT: screenshots added).
     
    cheers
    CorB
    Example_F2802xLaunchPadDemo.zip


  2. Like
    CorB got a reaction from larsie in Use CCS both for MSP430 and C2000   
    Odd. I simply reinstalled after the C2K launchpad arrived and choose to use the free license and I never had to do anything else to use the MSP430 ...
  3. Like
    CorB got a reaction from larsie in GLCD on C2K Launchpad   
    Hi all,
     
    The attached code shows how a small GLCD (boosterpack for MSP430, http://lars.roland.bz/lcd/ ) can be used on a C2K Launchpad.
    All the code used to display characters etc is identical to the code I was using on the MSP430 Launchpad, the only difference can be found in the SPI routines. On the MSP430 Launchpad I was using (based on Lars Rolands code) a MSP430G2553 chip with built-in SPI. On the C2K Launchpad I have not (yet) been able to use SPI on this GLCD so the code uses bitbanging to send the SPI commands to the GLCD.
     
    Running the code will display normal characters (6x8 pixels), large numbers (12x16 pixels) and uses the lower part of the GLCD as a graphic screen to display a simple bargraph. I am working on further expanding this GLCD library so all pixels on can be controlled by the user. On the MSP430 Launchpad was too limiting to achieve this, on the C2K launchpad this should not be a real issue allowing "live" graphics on this small screen.
     
    regards
     
    CorB
    PS. Thanks to all that have helped me during the problem-seeking/solving.

     
    LCD_SPI.zip
     
    EDIT: picture added
    This post has been promoted to an article
  4. Like
    CorB got a reaction from msptest6 in GLCD on C2K Launchpad   
    Hi all,
     
    The attached code shows how a small GLCD (boosterpack for MSP430, http://lars.roland.bz/lcd/ ) can be used on a C2K Launchpad.
    All the code used to display characters etc is identical to the code I was using on the MSP430 Launchpad, the only difference can be found in the SPI routines. On the MSP430 Launchpad I was using (based on Lars Rolands code) a MSP430G2553 chip with built-in SPI. On the C2K Launchpad I have not (yet) been able to use SPI on this GLCD so the code uses bitbanging to send the SPI commands to the GLCD.
     
    Running the code will display normal characters (6x8 pixels), large numbers (12x16 pixels) and uses the lower part of the GLCD as a graphic screen to display a simple bargraph. I am working on further expanding this GLCD library so all pixels on can be controlled by the user. On the MSP430 Launchpad was too limiting to achieve this, on the C2K launchpad this should not be a real issue allowing "live" graphics on this small screen.
     
    regards
     
    CorB
    PS. Thanks to all that have helped me during the problem-seeking/solving.

     
    LCD_SPI.zip
     
    EDIT: picture added
    This post has been promoted to an article
  5. Like
    CorB reacted to DanAndDusty in SOLVED: SPI on C2000 launchpad   
    Hey CorB, looks like we have been working on the same project. Ive also written some code (needs tidying still but will post when Im happy) to drive these LCDs. As Ive been using mine for the $4.30 booster pack using Hardware SPI wasn't an option for me so I was bit banging too. As there was ADC pins used I also used your code for setting GPIO pins.. lol..
     
    Given the extra ram on the C2000 I think it should be possible to code up a reasonable graphics library (add to buffer and then chuck out the whole buffer to the LCD).
     
    Anyways.. Thanks for the GPIO lib.. made things a lot easier to get my head around.
     
    Dan
  6. Like
    CorB reacted to RobG in 2.2" Color LCD Booster Pack with Touch   
    I am working on a new color LCD booster pack featuring 2.2" display.
    The board will work with two types of displays, one with touch screen and one without.
    TSC2046/ADS7846 controller or MCU's analog inputs can be used to process touch events.
     
    I expect some issues with the touch display since the spec sheet that was given to me is incorrect. As you can see on the image, only center LED is lit, indicating wrong connections or bad unit. Will have to sort it out.
     
    As for the software, support for those two will be added to my color LCD library. I might need a volunteer to write touch functions (short on free time.)
     



  7. Like
    CorB reacted to larsie in Simple robot, programmable using buttons   
    Here is a laser cut robot I
  8. Like
    CorB reacted to TI_Trey in How to use an ADCpin for GPIO ?   
    I noticed two things I'd like to comment on:
    The LEDs are setup such that they are on when the associated GPIO is low. The buffers driving them are non-inverting and the LEDs are setup such that the buffer sinks current. There is no design reason for this...its just how I implemented it at the time.
    Initially all the GPIOs are Hi-Z at reset. The buffers which drive the LEDs also have a Hi-Z input, so it very easy for a little bit of charge to build up and change the voltage on these nets when the GPIOs are unconfigured. This is purposeful as this is a learning tool and this makes a great remonstration of floating nodes.

    Trey
  9. Like
    CorB got a reaction from msptest6 in How to use an ADCpin for GPIO ?   
    Hi,
     
    After debugging and help from a fellowuser (DanAndDusty) the code is now working as planned, I will remove all older code to avoid people using the wrong coding. Here's the final setup, can be used in a library.
     
    Thanks for all that have helped,
     
    regards
    CorB
     

    typedef enum // create GPIO functionality { GPIO_Low=0, // GPIO_High, GPIO_Toggle // } GPIO_Function; //PINOUT SECTION //ADCpins are numbered>=100, when >200 they are also GPIO enabled pins #define ADCINA0 100 // #define ADCINA1 101 #define ADCINA2 202 // can be used as GPIO #define ADCINA3 103 #define ADCINA4 204 // can be used as GPIO #define ADCINA6 206 // can be used as GPIO #define ADCINA7 107 #define ADCINB1 109 #define ADCINB2 210 // can be used as GPIO #define ADCINB3 111 #define ADCINB4 212 // can be used as GPIO #define ADCINB6 214 // can be used as GPIO #define ADCINB7 115 //MSP430 pinnumber //LEFTSIDE PINS //VCC #define P1_0 ADCINA6 #define P1_1 GPIO_Number_28 #define P1_2 GPIO_Number_29 #define P1_3 GPIO_Number_34 #define P1_4 ADCINA4 //OK #define P1_5 GPIO_Number_18 #define P2_0 ADCINA2 #define P2_1 ADCINB2 #define P2_2 ADCINB4 //RIGHTSIDE PINS //GND #define P2_6 GPIO_Number_19 #define P2_7 GPIO_Number_12 //TEST ->NC //RST ->RST #define P1_7 GPIO_Number_16 #define P1_6 GPIO_Number_17 #define P2_5 GPIO_Number_6 #define P2_4 GPIO_Number_7 #define P2_3 ADCINB6 #define MSP_Button P1_2 #define MSP_LED0 P1_3 #define MSP_LED1 P1_6 //C2k PINNUMBERS //LEFT OUTER CONNECTOR //J1_1 VCC #define J1_2 ADCINA6 //OK #define J1_3 GPIO_Number_28 // #define J1_4 GPIO_Number_29 #define J1_5 GPIO_Number_34 #define J1_6 ADCINA4 //ok #define J1_7 GPIO_Number_18 // not ok blinks led02 #define J1_8 ADCINA2 // ok #define J1_9 ADCINB2 #define J1_10 ADCINB4 // blinks led0 //RIGHT OUTER CONNECTOR //J2_1 GND #define J2_2 GPIO_Number_19 // not OK blinks led3 #define J2_3 GPIO_Number_12 //J2_4 TEST ->NC //J2_5 RST ->RST #define J2_6 GPIO_Number_16 #define J2_7 GPIO_Number_17 //Not OK blinks led1 #define J2_8 GPIO_Number_6 //OK #define J2_9 GPIO_Number_7 //OK #define J2_10 ADCINB6 // not OK //LEFT INNER CONNECTOR //J5_1 VCC //J5_2 GND #define J5_3 ADCINA7 #define J5_4 ADCINA3 #define J5_5 ADCINA1 #define J5_6 ADCINA0 #define J5_7 ADCINB1 #define J5_8 ADCINB3 #define J5_9 ADCINB7 //J5_10 NC //RIGHT INNER CONNECTOR #define J6_1 GPIO_Number_0 #define J6_2 GPIO_Number_1 #define J6_3 GPIO_Number_2 #define J6_4 GPIO_Number_3 #define J6_5 GPIO_Number_4 #define J6_6 GPIO_Number_5 #define J6_7 GPIO_Number_32 #define J6_8 GPIO_Number_33 //J6_9 NC //J6_10 NC #define C2K_button GPIO_Number_12 #define C2K_Led0 GPIO_Number_0 #define C2K_Led1 GPIO_Number_1 #define C2K_Led2 GPIO_Number_2 #define C2K_Led3 GPIO_Number_3 ///***** functions void SetPin(uint32_t pinNumber, GPIO_Direction_e pinmode) // 32GPIOpins and 6 ADCPins can be set pinmode 0=input, 1=output { uint32_t realpin; EALLOW; realpin=pinNumber; if (pinNumber<32) // default "real" GPIOpins { if (pinNumber<16) // pins 0 to 15 { GpioCtrlRegs.GPAMUX1.all &= ~((unsigned long)3 << (realpin*2)); // set 2 bits for this pin to 00 = default GPIO function } if (pinNumber>15) // pins 16 to 31 { realpin=pinNumber-16; GpioCtrlRegs.GPAMUX2.all &= ~((unsigned long)3 << (realpin*2)); // set 2 bits for this pin to 00 = default GPIO function } if (pinmode==GPIO_Direction_Output) { GpioCtrlRegs.GPADIR.all |= ((unsigned long)1<<pinNumber); } else { GpioCtrlRegs.GPADIR.all &= ~((unsigned long)1<<pinNumber); // set the pin to input, set bit=0 } GpioCtrlRegs.GPAPUD.all |= ((unsigned long)1<<pinNumber); // always disable pullup by default, normal default after reset is GPIO0_11 are disabled, others are enabled } if (pinNumber>200) // ADC pins that can be used as GPIO { realpin=pinNumber-200; GpioCtrlRegs.AIOMUX1.all &= ~((unsigned long)3<<(realpin*2)); // write 2 bits (00=GPIO) in the AIOmux register if (pinmode==GPIO_Direction_Output) { GpioCtrlRegs.AIODIR.all |= ((unsigned long)1<<realpin); // set as output set bit=1 } else { GpioCtrlRegs.AIODIR.all &= ~((unsigned long)1<<realpin); // set as input set bit=0 } } EDIS; } // set pin low, high or togglepin void PinData(uint32_t pinNumber, GPIO_Function data) { uint32_t realpin; EALLOW; realpin=pinNumber; if (pinNumber<32) { switch (data) { case 0: GpioDataRegs.GPADAT.all &= ~((unsigned long)1<<realpin); // set the pin low break; case 1: GpioDataRegs.GPADAT.all |= ((unsigned long)1<<realpin); // set the pin high break; case 2: GpioDataRegs.GPATOGGLE.all |= ((unsigned long)1<<realpin); // toggle pin break; } } if (pinNumber>200) // adc GPIO pins { realpin=pinNumber-200; switch (data) { case 0: GpioDataRegs.AIODAT.all &= ~((unsigned long)1<<realpin); // set the pin low break; case 1: GpioDataRegs.AIODAT.all |= ((unsigned long)1<<realpin); // set the pin high break; case 2: GpioDataRegs.AIOTOGGLE.all |= ((unsigned long)1<<realpin); // toggle pin break; } } EDIS; } //**** abstract functions void InputPin(uint16_t pinNumber) // set for the 1st 32 GPIO pins and all ADCpins { SetPin(pinNumber,GPIO_Direction_Input); } void OutputPin(uint16_t pinNumber) // set for the 1st 32 GPIO pins and all ADCpins { SetPin(pinNumber,GPIO_Direction_Output); } void PinHigh(uint16_t pinNumber) { PinData(pinNumber, GPIO_High); } void PinLow(uint16_t pinNumber) { PinData(pinNumber, GPIO_Low);} void PinToggle(uint16_t pinNumber) { PinData(pinNumber, GPIO_Toggle); }
  10. Like
    CorB reacted to DanAndDusty in SOLVED :Code issues: automated setting of GPADIR for GPIOpins >15 problematic   
    I don't have access to my dev terminal here at the moment.. But I seem to remember hitting something similar on a different processor a while ago. Does it work if you cast the 1? I.E.
     

    GpioCtrlRegs.GPADIR.all |= ((unsigned long)1<<pinNumber);
  11. Like
    CorB got a reaction from Oppa in Hello world led+button   
    Hi,
     
    Thanks for sharing this !
     
    This part of the code:

    // If running from flash copy RAM only functions to RAM #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif
     
    should not be place before void main(), when I then compile the code for FLASH based operation it raises compiler-errors.
    Ive placed it inside the code after the line:

    PLL_setup(myPll .... )
     
    Would be nice to set the code also up for an interrupt based action instead of a polling loop. Ive tried to use the external_interrupt code to build something like that but thusfar without a blinking led.
     
    cheers
    CorB
  12. Like
    CorB got a reaction from timotet in How to use an ADCpin for GPIO ?   
    Hi,
     
    In the code below I have created 2 functions InputPin and OutputPin that can be used to set a GPIO (and soon ADC)-pin to be used as either input or output. You can use either the predefined GPIO_number setup or MSP430 pins or C2kPins as a name.
    So
    InputPin(GPIO_Number_12) //button
    InputPin(J2_3)
    InputPin(P2_7)
    all set the same pin as an inputpin.
     
    Surely not perfect and I am also working on getting the ADCpins to be controlled in the same simple fashion.
     
    cheers
    Cor
    PS. It seems that we cannot use all the ADCpins as GPIO (see page 89 in http://www.ti.com/li...3c/sprufn3c.pdf), the AIOMux1 register only allows AIO2/4/6/10/12/14 to be used as GPIO. This corresponds to ADCINA2, ADCINA4,ADCINA6, ADCINB2, ADCINB4, ADCINB6 on the launchpad.These are the ADCpins on J1 and J2 (or P1 and P2) so they can also be used with MSP430 Boosterpacks
     
    .... code removed ... see later message #15
  13. Like
    CorB got a reaction from timotet in How to use an ADCpin for GPIO ?   
    Here's the list of all pins with corresponding GPIO and ADCnames, I am using this as a reference but will try to create a function that allows easy and simple setting of all the GPIO pins. I am now also going for a naming style that is equal to the pinnumber/name on the launchpad, so J1 and J2 (outer pingroups) and J5 / J6 for the inner pingroups.
     
     
    .... code removed see final coding in later message #15
  14. Like
    CorB got a reaction from PowerX in Interrupt based button and PORT_A leds   
    Hi,
     
    Here's a simple example (based on a crossover of TI;s example code External_interrupt and LaunchpadDemo) that detects a buttonpress on the C2000 Launchpad (GPIO12), processes the press in an interrupt and shows the no of buttonpresses using the Port_A LED setup. The button isnt properly debounced yet it seems but its working. The code isnt the shortest possible I guess.
     
    regards
    CorB
     

    //############################################################################# // // File: /Example_F2802xButtonInterrupt.c // // Title: F2802x Button Interrupt test program, will show successive presses on PORT_A leds // // Group: C2000 Launchpad // Target Device: TMS320F28027 // // Code based on TIs examples External_interrupt and LaunchpadDemo // ########################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #include "f2802x_common/include/clk.h" #include "f2802x_common/include/flash.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/pwr.h" #include "f2802x_common/include/wdog.h" // Prototype statements for functions found within this file. interrupt void xint1_isr(void); char counter; // the counter showing the no of button presses CLK_Handle myClk; FLASH_Handle myFlash; GPIO_Handle myGpio; PIE_Handle myPie; void main(void) { CPU_Handle myCpu; PLL_Handle myPll; WDOG_Handle myWDog; // Initialize all the handles needed for this application myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj)); myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj)); myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj)); myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj)); myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj)); myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj)); // Perform basic system initialization WDOG_disable(myWDog); CLK_enableAdcClock(myClk); (*Device_cal)(); //Select the internal oscillator 1 as the clock source CLK_setOscSrc(myClk, CLK_OscSrc_Internal); // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2 PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2); // Disable the PIE and all interrupts PIE_disable(myPie); PIE_disableAllInts(myPie); CPU_disableGlobalInts(myCpu); CPU_clearIntFlags(myCpu); // If running from flash copy RAM only functions to RAM #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Setup a debug vector table and enable the PIE PIE_setDebugIntVectorTable(myPie); PIE_enable(myPie); // Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (intVec_t)&xint1_isr); // Enable XINT1 in the PIE: Group 1 interrupt 4 // Enable INT1 which is connected to WAKEINT PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1); CPU_enableInt(myCpu, CPU_IntNumber_1); // Enable Global Interrupts CPU_enableGlobalInts(myCpu); // Configure GPIO 0-3 as outputs GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output); // GPIO12 input GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input); GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable); // important !! // GPIO12 is XINT1 GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1); // Configure XINT1 PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_FallingEdge); // Enable XINT1 PIE_enableExtInt(myPie, CPU_ExtIntNumber_1); counter=0; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); for(; { /// forever loop } } interrupt void xint1_isr(void) { //GPIO_toggle(myGpio, GPIO_Number_0); // toggle LED0 counter++; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); DELAY_US(100000); // Acknowledge this interrupt to get more from group 1 PIE_clearInt(myPie, PIE_GroupNumber_1); } //=========================================================================== // No more. //===========================================================================
  15. Like
    CorB got a reaction from msptest6 in How to use an ADCpin for GPIO ?   
    Hi,
     
    In the code below I have created 2 functions InputPin and OutputPin that can be used to set a GPIO (and soon ADC)-pin to be used as either input or output. You can use either the predefined GPIO_number setup or MSP430 pins or C2kPins as a name.
    So
    InputPin(GPIO_Number_12) //button
    InputPin(J2_3)
    InputPin(P2_7)
    all set the same pin as an inputpin.
     
    Surely not perfect and I am also working on getting the ADCpins to be controlled in the same simple fashion.
     
    cheers
    Cor
    PS. It seems that we cannot use all the ADCpins as GPIO (see page 89 in http://www.ti.com/li...3c/sprufn3c.pdf), the AIOMux1 register only allows AIO2/4/6/10/12/14 to be used as GPIO. This corresponds to ADCINA2, ADCINA4,ADCINA6, ADCINB2, ADCINB4, ADCINB6 on the launchpad.These are the ADCpins on J1 and J2 (or P1 and P2) so they can also be used with MSP430 Boosterpacks
     
    .... code removed ... see later message #15
  16. Like
    CorB got a reaction from msptest6 in How to use an ADCpin for GPIO ?   
    Here's the list of all pins with corresponding GPIO and ADCnames, I am using this as a reference but will try to create a function that allows easy and simple setting of all the GPIO pins. I am now also going for a naming style that is equal to the pinnumber/name on the launchpad, so J1 and J2 (outer pingroups) and J5 / J6 for the inner pingroups.
     
     
    .... code removed see final coding in later message #15
  17. Like
    CorB got a reaction from larsie in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Since my last mail I have updated the code, the code below is more sensitivy and also stable in receiving the OOK signals. Next to this I also have developed a more general OOK-sniffer that can display incoming OOK signals at 434 MHZ (or another frequecny) by reporting the signal ON/OFF times in microseconds. If anybody is interested I will publish that code.
     
    void SetupOOKreader()
    {
    TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE
     
    //set at 433,92 Mhz
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x13); //Freq control word, mid byte.
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0xE9); //Freq control word, low byte.
     
    TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x4D); // RX bandwidth and datarate MSB
     
    TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0x80); // receiver gain
    TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 0x00); //use no channel
     
    TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode
     
    TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output
    __delay_cycles(100000);
     
    TI_CC_SPIStrobe(TI_CCxxx0_SRX); // directly start the receivermode
     
    }
  18. Like
    CorB got a reaction from Oppa in Interrupt based button and PORT_A leds   
    Hi,
     
    Here's a simple example (based on a crossover of TI;s example code External_interrupt and LaunchpadDemo) that detects a buttonpress on the C2000 Launchpad (GPIO12), processes the press in an interrupt and shows the no of buttonpresses using the Port_A LED setup. The button isnt properly debounced yet it seems but its working. The code isnt the shortest possible I guess.
     
    regards
    CorB
     

    //############################################################################# // // File: /Example_F2802xButtonInterrupt.c // // Title: F2802x Button Interrupt test program, will show successive presses on PORT_A leds // // Group: C2000 Launchpad // Target Device: TMS320F28027 // // Code based on TIs examples External_interrupt and LaunchpadDemo // ########################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #include "f2802x_common/include/clk.h" #include "f2802x_common/include/flash.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/pwr.h" #include "f2802x_common/include/wdog.h" // Prototype statements for functions found within this file. interrupt void xint1_isr(void); char counter; // the counter showing the no of button presses CLK_Handle myClk; FLASH_Handle myFlash; GPIO_Handle myGpio; PIE_Handle myPie; void main(void) { CPU_Handle myCpu; PLL_Handle myPll; WDOG_Handle myWDog; // Initialize all the handles needed for this application myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj)); myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj)); myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj)); myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj)); myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj)); myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj)); // Perform basic system initialization WDOG_disable(myWDog); CLK_enableAdcClock(myClk); (*Device_cal)(); //Select the internal oscillator 1 as the clock source CLK_setOscSrc(myClk, CLK_OscSrc_Internal); // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2 PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2); // Disable the PIE and all interrupts PIE_disable(myPie); PIE_disableAllInts(myPie); CPU_disableGlobalInts(myCpu); CPU_clearIntFlags(myCpu); // If running from flash copy RAM only functions to RAM #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Setup a debug vector table and enable the PIE PIE_setDebugIntVectorTable(myPie); PIE_enable(myPie); // Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (intVec_t)&xint1_isr); // Enable XINT1 in the PIE: Group 1 interrupt 4 // Enable INT1 which is connected to WAKEINT PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1); CPU_enableInt(myCpu, CPU_IntNumber_1); // Enable Global Interrupts CPU_enableGlobalInts(myCpu); // Configure GPIO 0-3 as outputs GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output); // GPIO12 input GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input); GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable); // important !! // GPIO12 is XINT1 GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1); // Configure XINT1 PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_FallingEdge); // Enable XINT1 PIE_enableExtInt(myPie, CPU_ExtIntNumber_1); counter=0; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); for(; { /// forever loop } } interrupt void xint1_isr(void) { //GPIO_toggle(myGpio, GPIO_Number_0); // toggle LED0 counter++; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); DELAY_US(100000); // Acknowledge this interrupt to get more from group 1 PIE_clearInt(myPie, PIE_GroupNumber_1); } //=========================================================================== // No more. //===========================================================================
  19. Like
    CorB got a reaction from msptest6 in Interrupt based button and PORT_A leds   
    Hi,
     
    Here's a simple example (based on a crossover of TI;s example code External_interrupt and LaunchpadDemo) that detects a buttonpress on the C2000 Launchpad (GPIO12), processes the press in an interrupt and shows the no of buttonpresses using the Port_A LED setup. The button isnt properly debounced yet it seems but its working. The code isnt the shortest possible I guess.
     
    regards
    CorB
     

    //############################################################################# // // File: /Example_F2802xButtonInterrupt.c // // Title: F2802x Button Interrupt test program, will show successive presses on PORT_A leds // // Group: C2000 Launchpad // Target Device: TMS320F28027 // // Code based on TIs examples External_interrupt and LaunchpadDemo // ########################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #include "f2802x_common/include/clk.h" #include "f2802x_common/include/flash.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/pwr.h" #include "f2802x_common/include/wdog.h" // Prototype statements for functions found within this file. interrupt void xint1_isr(void); char counter; // the counter showing the no of button presses CLK_Handle myClk; FLASH_Handle myFlash; GPIO_Handle myGpio; PIE_Handle myPie; void main(void) { CPU_Handle myCpu; PLL_Handle myPll; WDOG_Handle myWDog; // Initialize all the handles needed for this application myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj)); myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj)); myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj)); myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj)); myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj)); myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj)); // Perform basic system initialization WDOG_disable(myWDog); CLK_enableAdcClock(myClk); (*Device_cal)(); //Select the internal oscillator 1 as the clock source CLK_setOscSrc(myClk, CLK_OscSrc_Internal); // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2 PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2); // Disable the PIE and all interrupts PIE_disable(myPie); PIE_disableAllInts(myPie); CPU_disableGlobalInts(myCpu); CPU_clearIntFlags(myCpu); // If running from flash copy RAM only functions to RAM #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Setup a debug vector table and enable the PIE PIE_setDebugIntVectorTable(myPie); PIE_enable(myPie); // Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (intVec_t)&xint1_isr); // Enable XINT1 in the PIE: Group 1 interrupt 4 // Enable INT1 which is connected to WAKEINT PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1); CPU_enableInt(myCpu, CPU_IntNumber_1); // Enable Global Interrupts CPU_enableGlobalInts(myCpu); // Configure GPIO 0-3 as outputs GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output); // GPIO12 input GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input); GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable); // important !! // GPIO12 is XINT1 GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1); // Configure XINT1 PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_FallingEdge); // Enable XINT1 PIE_enableExtInt(myPie, CPU_ExtIntNumber_1); counter=0; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); for(; { /// forever loop } } interrupt void xint1_isr(void) { //GPIO_toggle(myGpio, GPIO_Number_0); // toggle LED0 counter++; GPIO_setPortData(myGpio, GPIO_Port_A, (~(counter) & 0x0F)); DELAY_US(100000); // Acknowledge this interrupt to get more from group 1 PIE_clearInt(myPie, PIE_GroupNumber_1); } //=========================================================================== // No more. //===========================================================================
  20. Like
    CorB reacted to PowerX in Hello world led+button   
    Hello,
    This is my first very simple test with the c2k launchpad, it simply lights up a led (gpio0) a turns it off when the button (gpio12) is pressed.
    Below is my code for it. Hope you like it.
     

    // // c2k launchpad led Hello world 1.0 + button // //includes #include "DSP28x_Project.h" #include "f2802x_common/include/clk.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/wdog.h" #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif //main void main() { //wdog WDOG_Handle myWDog; myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj)); WDOG_disable(myWDog); //clk&pll CLK_Handle myClk; PLL_Handle myPll; myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj)); CLK_setOscSrc(myClk, CLK_OscSrc_Internal); PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2); //set gpio GPIO_Handle myGpio; myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj)); //set led gpio0 GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output); GPIO_setHigh(myGpio, GPIO_Number_0); //set button gpio12 GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input); GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable); //loop for(; { // if gpio12 button is pressed led on-off once if(GPIO_getData(myGpio, GPIO_Number_12) == 1) { GPIO_setLow(myGpio, GPIO_Number_0); DELAY_US(1000000); GPIO_setHigh(myGpio, GPIO_Number_0); } } }
  21. Like
    CorB got a reaction from Nytblade in MSP430 meets LaCrosse Temperature/Humidity sensor TX3TH   
    Since my last mail I have updated the code, the code below is more sensitivy and also stable in receiving the OOK signals. Next to this I also have developed a more general OOK-sniffer that can display incoming OOK signals at 434 MHZ (or another frequecny) by reporting the signal ON/OFF times in microseconds. If anybody is interested I will publish that code.
     
    void SetupOOKreader()
    {
    TI_CC_SPIStrobe(TI_CCxxx0_SIDLE); // set IDLE
     
    //set at 433,92 Mhz
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x10); // Freq control word, high byte
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x13); //Freq control word, mid byte.
    TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0xE9); //Freq control word, low byte.
     
    TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x4D); // RX bandwidth and datarate MSB
     
    TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2,0x80); // receiver gain
    TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 0x00); //use no channel
     
    TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x32); //asynchronous mode
     
    TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x0E); //GDO0Output Pin Configuration asynchronous output
    __delay_cycles(100000);
     
    TI_CC_SPIStrobe(TI_CCxxx0_SRX); // directly start the receivermode
     
    }
  22. Like
    CorB got a reaction from OppaErich in FRAM for Dummies   
    Nope, I havent seen anything yet
  23. Like
    CorB reacted to oPossum in [Closed]Tell us your idea and win a free C2000 Launchpad.   
    My first project would be to get the LogicBoost logic analyzer to work with the C2000 Launchpad - because the MSP430 Launchpad app UART sucks and the C2000 Launchpad FT2232 UART rocks.
     
    The SMCLK output on P1.4 is used to clock the acquisition memory on the LogicBoost. This was done to allow up to 16 Msps sample rate. Using PWM on the MSP430 would have limited it to 8 Msps, The plan is to jumper one of the ePWM outputs of the C2000 to the P1.4 pin so it can provide a clock up to 20 MHz - the maximum spec for the SPI RAM chips. So using the C2000 will increase the sample rate a little and greatly improve the transfer rate to the host PC.
     
    I am also interested in using ePWM as an audio 'DAC' for music synth applications. Hope to get 14 bits resolution with simple PWM and maybe use the CLA to do delta-sigma modulation for 18+ bits resolution. That would make the C2000 Launchpad and Piccolo control stick great platforms for eXperimentation with digital music synthesis.
  24. Like
    CorB reacted to Rei Vilo in LaunchPad Pin Assignment   
    Something like this?
     
    Please refer to the Energia wiki at :arrow: http://github.com/energia/Energia/wiki/Hardware
  25. Like
    CorB reacted to larsie in Laser cut box for launchpad   
    OK, sorry to repeat myself, but I made another iteration of the box design. This one looks better. The top is now glued on, and the side-walls are thin and fit outside the top. Inspired by iPhone. I guess they could sue me :-)
     
    Well, it is best described by a picture. The design is on thingiverse here: http://www.thingiverse.com/thing:28913
     

     

×
×
  • Create New...