Showing posts with label LaunchPad. Show all posts
Showing posts with label LaunchPad. Show all posts

CC3200 with Energia

CC3200 with Energia (Arduino IDE like environment)

Energia is very similar framework to Arduino IDE that support TI MSP430 LaunchPad and also other TI LaunchPad including CC3200. I have been using CCS6 to build my CC3200 projects, but as one of the Arduino user, I tried to establish this Energia IDE to see how it works. Here is the steps.
  1.  Install Windows driver
    Download "cc3200_drivers_win.zip" from the following link and execute DPinst.exe for Windows 32bit or DPinst64.exe for Windows 64 bit after unzip the package.http://energia.nu/files/cc3200_drivers_win.zip
    Make sure CC3200 board is not connected when install the driver.
    You can connect the board after the installation, and the board will be recognized automatically. 


  2.  Install Energia
    Download the latest package from the following link.http://energia.nu/download/
    Unzip the energia-0101EXXXX-windows.zip file to a desired location.
  3.  Hardware setup
    To make it work with Energia, you need to modify the board setting. However, this is not so complicated and basically just change the jumper setting of CC3200 LaunchPad and use single wire to connect 2 pins which is top pin of JP8 and bottom pin of SOP2 with the USB connector facing up.
    You can see the details here.
  4.  Launch Energia and run a project
    Double clike Energia.exe. You will see the following which is very similar to Arduion IDE except the color. 
















    |

    Select "Tool > Boards > LaunchPad w/ CC3200"
    .

















    Select "Tool > Serial Port > COMxx". In my case, it is COM33.














    Select "File > Examples > 1.Basics > Blink".



    It will launch new window as below, and click "Verify" to compile.
    After it is successfully compiled, click upload button and you would see the red LED (P64) blinking around every 2 seconds.





Hardware:
CC3200 Launchpad

Reference:     
How to set up Energia on Windows
Upgrading the CC3200 Firmware
CC3200 Jumper Settings

CC3200 Capture Compare PWM (CCP)

CC3200 Capture Compare PWM (CCP)

I needed to use external clock to count up/down the timer for my CC3200 project. CC3200 support this as I can see in the section 9.3.2.2 "Input Edge Count Mode" of CC3200 technical reference manual. The implementation was not so difficult, and here is how I tested it.
  1.  Assign GPIO pin and CCP/timer
    I decided to use GPIO0 pin
    (PIN_50) on CC3200 launchpad, and use the pin as GP_CCP00 that is assigned as timer0 clock input. Refer to technical reference manual for "pin mux config mode value". In my case, Pin 50 should be "7" to configure it as timer capture port.



    You can also refer to the same manual to see which timer that GP_CCP00 is connected. GT_CCP00 I use is for 16-bit timer 0 as below.




    The block diagram shown before the above table is quite useful to understand how it is internal connected.




    Based on above configuration, I added following lines
    in the pin configuration file.
    //
    // Enable Peripheral Clocks
    //
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_50(GPIO00) for EXTCLK GPIOInput
    //
    MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA0_BASE, 0x01, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_50 for TIMERCP0 GT_CCP00
    //
    MAP_PinTypeTimer(PIN_50, PIN_MODE_7); // refer to datasheet pin list

  2. Configure Timer and Interrupt registers
    This is the configuration for my edge count timer and timer interrupt.
    void EXTCLKInit(P_INT_HANDLER EXTCLKInterruptHdl)
    {
        //
        // Register timer interrupt hander
        //
        MAP_TimerIntRegister(TIMERA0_BASE,TIMER_A,EXTCLKInterruptHdl);

        //
        // Configure the timer in edge count mode
        //
    MAP_TimerConfigure(TIMERA0_BASE,(TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT_UP));

        //
        // Set the detection edge
        //             
    MAP_TimerControlEvent(TIMERA0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);

        //
        // Set the reload value
        //
        MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,0xffff);

        //
        // Set Match Count Value for Timer Interrupt
        //
        MAP_TimerMatchSet(TIMERA0_BASE,TIMER_A,374);
    }
    You can change MAP_TimerMatchSet parameter to tune the timing. My setting is "374".
  3. Configure Interrupt handler
    This is the interrupt handler that is called by the above timer interrupt.
    For the quick test purpose, you can just add LED toggle function.

    void EXTCLKIntHandler(void)
    {
        //Clear EXTCLK Timer Interrupt Flag
        ClearEXTCLKInt();    // Toggle LED
        //LED1 = 1; //LED on

        //LED1 = 0; //LED off
    }
     
Hardware:
    CC3200 Launchpad
Summary:


Reference:     
CC3200 Technical Reference Manual

Use low price LCD on CC3200-LAUNCHPADXL

In the previous post (almost 1 year ago), I tried using a low-price LCD, TD-T14ST2G2360-5. I ported it onto CC3200-LAUNCHPADXL.




Here's the connection between the launchpad and LCD.
The CCS project archive can be downloaded here.


Stellaris LaunchPad working I2C code example

I tried using Stellaris LaunchPad evaluation board (EK-LM4F120XL) with I2C communication and I had a trouble. I'd like to show you a working I2C code example here to avoid wasting time.

The reason of the difficulty was that the Launch Pad I2C pins for booster pack were shared with other GPIO pins in the default configuration. Therefore you need to configure the pins in right way.

See the function SetupI2C() below.


#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_uart.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_i2c.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "driverlib/i2c.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.h"

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#define I2C_SLAVE_ADDRESS       0x60

/*****************************************************************************/
/* This function returns:
 * I2C_MASTER_ERR_NONE, I2C_MASTER_ERR_ADDR_ACK, I2C_MASTER_ERR_DATA_ACK, or
 * I2C_MASTER_ERR_ARB_LOST.
 */
static unsigned long WaitI2CDone( unsigned int long ulBase){
    // Wait until done transmitting
    while( I2CMasterBusy(I2C3_MASTER_BASE));
    // Return I2C error code
    return I2CMasterErr( I2C3_MASTER_BASE);
}

static void SetupI2C(){
    /***
     * Shared Pin Setting
     */
    // You need to set the shared pins as input.
    GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    // Change the pad configuration to WPU
    GPIOPadConfigSet( GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU);

    /***
     * I2C Setting
     */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0); //  special I2CSCL treatment for M4F devices
    GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);

    GPIOPinConfigure(GPIO_PD0_I2C3SCL);
    GPIOPinConfigure(GPIO_PD1_I2C3SDA);

    SysCtlPeripheralEnable( SYSCTL_PERIPH_I2C3);

    I2CMasterInitExpClk( I2C3_MASTER_BASE, SysCtlClockGet(), false);
    SysCtlDelay(10000);
}


int main(void) {
    uint8_t data = 0;
    int16_t i2c_err = I2C_MASTER_ERR_NONE;

    //
    // Setup the system clock to run at 50 Mhz from PLL with crystal reference
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
                    SYSCTL_OSC_MAIN);
    SysCtlDelay(10000);

    SetupI2C();

    /** Send register address.
     */
    I2CMasterSlaveAddrSet( I2C3_MASTER_BASE, I2C_SLAVE_ADDRESS, false);   // false = write, true = read
    // Set register address of AK8963
    I2CMasterDataPut( I2C3_MASTER_BASE, 0x00);
    // Start sending data
    I2CMasterControl( I2C3_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    WaitI2CDone( I2C3_MASTER_BASE);

    /** Set read mode.
     */
    I2CMasterSlaveAddrSet( I2C3_MASTER_BASE, I2C_SLAVE_ADDRESS, true);   // false = write, true = read

    /** Single Read
     */
    I2CMasterControl( I2C3_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    if( (i2c_err = WaitI2CDone( I2C3_MASTER_BASE)))
        data = 0xff;
    else
        data = I2CMasterDataGet(I2C3_MASTER_BASE);

    return 0;
}


[AKM Chip Booster] Audio ADC AK5704 PCB Design

Designing a PCB prototype with AK5704 is not so difficult and I show an example with my design. People who are not familiar with AK5704,...