顯示具有 nrf51822 標籤的文章。 顯示所有文章
顯示具有 nrf51822 標籤的文章。 顯示所有文章

2018年1月5日 星期五

[nRF52832] Unboxing Nordic POWER PROFILER KIT


1. 最近拿到一張從來都沒用過的板子, 主要是用來量測板子上的動態功耗.

2. 官網的描述連結: Nordic Power Profiler

3. 開箱照片:


2017年6月3日 星期六

[nRF51] Corsair Concept Zeus: Gaming Mouse with Wireless Charging

前陣子被操到不要不要的案子, 終於在2017 Computex發表, 而且居然還得獎了, 真是不可思議啊.....


2017年3月26日 星期日

[Life] Unboxing The RF Explorer

1. 最近購入了一台rf explorer, 主要的目的是用來觀察rf protocol的跳頻是否跟程式所寫的方式相同.


2016年12月29日 星期四

How to change nRF51 Clock Source in ble_stack_init function?

1. 最近在測試nRF51的板子實作2.4G/BLE雙模切換時, 發現只要切到ble mode, 程式就會當掉, 查了一下才發現程式是當在static void ble_stack_init(void)這個function裡面.



2. 進去trace code後, 才發現是設定上的錯誤, 由於硬體板子上並沒有XTAL元件, 只要一進去ble_stack_init() function, 就會出現死當.



3. 因此我們必須將clock source由XTAL改為RC.


.rc_ctiv = 16, // Interval in 0.25 s, 16 * 0.25 = 4 sec
.rc_temp_ctiv = 2, // Check temperature every .rc_ctiv, but calibrate every .rc_temp_ctiv 
This configuration will set RC oscillator, and check for temperature delta every 4 second, and calibrate the RC every 8 second.
4. 修改完成.

2016年2月3日 星期三

nRF51x22 Simple KeyScan

1. Test Schematic: (KEY1 = GPIO25)












2. Button.c
--------------------------------------------------------------------------------------------------------------------

#include "Button.h"

uint16_t  DebounceKeyCnt = 0;
uint8_t   KeyValue = 0; 
uint8_t   KeyState = 0;

void Button_Init(void)
{
 nrf_gpio_pin_dir_set(Button_GPIO_Pin,NRF_GPIO_PIN_DIR_INPUT);   //configurate pin direction to input
 nrf_gpio_cfg_input(Button_GPIO_Pin, NRF_GPIO_PIN_PULLUP); //pull-up
}

uint8_t KeyScan(void)
{
 KeyValue = nrf_gpio_pin_read(Button_GPIO_Pin);
 
 #ifdef high_active
  KeyValue = KeyValue;    //active high
 #endif
 
 #ifdef low_active
  KeyValue = !(KeyValue); //active low
 #endif
  
 if(KeyValue >= 1)
 {
  DebounceKeyCnt++;
 
                if(DebounceKeyCnt >= 5)
                {
   DebounceKeyCnt = 0;  
   KeyState = 1;
                }    
 }
 else
 {
  DebounceKeyCnt = 0;
  KeyState = 0;   
 } 
        
 return(KeyState);
}



3. Button.h
---------------------------------------------------------------------------------------------------------------------


#include "nrf_drv_gpiote.h"

#define Button_GPIO_Pin 25

#if 0
 #define high_active
#else
 #define low_active
#endif

void Button_Init(void);
uint8_t KeyScan(void);



nRF51x22 Simple Timer Code

1. 定義一個固定時間觸發的Timer.


2. 只需要Timer Init 和 Timer Handler這兩個function就可以用了.

Timer Init:
-------------------------------------------------------------------------------------------------------------------------
void Timer_Init(int32_t deltatime)  
{
    
    NRF_TIMER2->BITMODE     = TIMER_BITMODE_BITMODE_16Bit; //Set counter to 16 bit resolution
    NRF_TIMER2->MODE        = TIMER_MODE_MODE_Timer;
    NRF_TIMER2->PRESCALER   = 9;               //16MHz/(2^9) = 16MHz/512 = 31250Hz = 32usec
    NRF_TIMER2->CC[2]       = (deltatime/32);            //250 = 8msec , 500 = 16msec
    NRF_TIMER2->INTENSET    = TIMER_INTENSET_COMPARE2_Enabled << TIMER_INTENSET_COMPARE2_Pos;
    NRF_TIMER2->SHORTS      = (TIMER_SHORTS_COMPARE1_CLEAR_Enabled << TIMER_SHORTS_COMPARE1_CLEAR_Pos);
                
    NVIC_ClearPendingIRQ(TIMER2_IRQn);
    NVIC_SetPriority(TIMER2_IRQn,3);
    NVIC_EnableIRQ(TIMER2_IRQn);  
    NRF_TIMER2->TASKS_START = 1; 
}



Timer Handler:
-------------------------------------------------------------------------------------------------------------------------

void TIMER2_IRQHandler(void)  
{
    if((NRF_TIMER2->EVENTS_COMPARE[2] == 1) && (NRF_TIMER2->INTENSET & TIMER_INTENSET_COMPARE2_Msk))
    {
 NRF_TIMER2->EVENTS_COMPARE[2] = 0;
   
 //nrf_gpio_pin_toggle(20);      //debug gpio
       
 NRF_TIMER2->TASKS_CLEAR = 1; 
    }
}

3. 假設需要定義一個固定每10msec會觸發的Timer, 可以在Init的時候帶入這樣的參數.     Timer_Init(10000);