I'm using nRF Development Kit which includes two nRF51822 chips which are mounted on PCB with a matched antenna.The kit also includes a compact nRF51822 USB dongle that can act as a Bluetooth low energy master emulator when developing Bluetooth low energy applications. Unfortunately we couldn't buy a nRFgo Starter kit. So I will describe how to program the nRF chip without a nRFgo Starter Kit.
Connect pin2 and pin3 together and connect them to 3.3V in K1 header. Then find a ground signal from the board (see P5 header) and connect it to the GND of the power source.
Initializing UART
To read the data via UART module I used USB to Serial converter module which can be easily buy from ebay. But in my next post, I will describe how to read data via BLE module in the chip. Before using the uart module you must configure the baud rate , hardware flow control and pins.I did not use any hardware flow control. So I set HDFC to false.
#define RX_PIN_NUMBER 11
#define TX_PIN_NUMBER 9
#define CTS_PIN_NUMBER 10
#define RTS_PIN_NUMBER 8
#define HWFC false
Set the baud rate to 9600.
Initializing I2C
MMA7660 accelerometer module is specially designed for identify gestures. It communicates with the micro controller via I2C interface. So we must activate the I2C interface of nrf51822 SoC. In order to do so, twi_hw_master.c file should be imported to your workspace. By calling "twi_master_init(void)" function in the above C file,we can initialize hardware I2C interface of the chip. By default SDA and SCK pins are 24U and 25U. By reading the data sheet of accelerometer module you would get better understand how it communicates with external micro controller via I2C interface. In the data sheet they have mentioned the I2C frequency the accelerometer works with.
There are some issues with I2C interface. Most of the time devices will not communicate properly if the connections between them are loos. Connecting wires should shorter as possible.
SDA and SCL pins should be connected to pull up resisters. In the breakout board I bought from ebay got those pull up resisters. So I was able to connect the breakout board's SCL and SDA pins directly to the chip.
So we have done the basic setup to communicate with accelerometer and get data out from it.