This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can I transmit clock signal directly to GPIO pin without using timers?

Hi!

I am using nrf51DK with s110 soft device loaded on it to read data from Bosch BMA180 accelerometer using I2C interface. I would like to use clock prescaller and transmit a signal from it directly to the pin P07 (clock signal for I2C). The only resolution i found is this code:

#include "nrf.h"
#include "nrf_gpiote.h"
#include "bsp.h"

#define OUTPUT_PIN_NUMBER (1)

int main(void)
{
    // Configure OUTPUT_PIN_NUMBER as an output.
    nrf_gpio_cfg_output(OUTPUT_PIN_NUMBER);

    // Configure GPIOTE channel 0 to toggle the pin state
    nrf_gpiote_task_config(0, OUTPUT_PIN_NUMBER, \
                           NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);

    // Configure PPI channel 0 to toggle OUTPUT_PIN on every TIMER2 COMPARE[0] match.
    NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0];
    NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];

    // Enable PPI channel 0
    NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos);

    // Start 16 MHz crystal oscillator .
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART    = 1;

    // Wait for the external oscillator to start up.
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0){}

    // Configure timer 2
    NRF_TIMER2->MODE      = TIMER_MODE_MODE_Timer;
    NRF_TIMER2->BITMODE   = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos;
    NRF_TIMER2->PRESCALER = 0;
    NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos;

    // Clears the timer, sets it to 0.
    NRF_TIMER2->TASKS_CLEAR = 1;

    // Load the initial values to TIMER2 CC registers.
    NRF_TIMER2->CC[0] = 2;

    // Start the timer
    NRF_TIMER2->TASKS_START = 1;

    for(;;){}
}

Is it possible to do not use any timers, just pure clock signal, prescale it and transmit it to P07 pin? I saw on block diagram of LPC1102/1104 processor that the clock has its own divider which i could use: image description

but i dont know if it is the same model as used in nrf51DK.

I just want to know if i have to use timers or can i use just divided clock signal, and if it is possible, how can i do it, which functions should i use? And if anyone could tell me the exact model of processor in nrf51DK so i could find it block diagram? it would make my work much easier.

Thank you in advance

Parents Reply Children
No Data
Related