设为首页收藏本站

Discuz! Board

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 1806|回复: 0

nrf52840 ble_uart參考例程中加入oled,結果oled無法顯示(自問自答)

[复制链接]

3

主题

5

帖子

85

积分

注册会员

Rank: 2

积分
85
leo2m4a 发表于 2021-11-11 23:19:08 | 显示全部楼层 |阅读模式
隨附的藍芽遙控器的範例中只有開關led,沒有加入oled.我就使用一個ble uart的例程.希望將收到的第一個byte顯示在oled上.故參考oled的例程.想法為1.首先在main中挑一個地方執行oled initialize.
2.收到手機APP來的UART data將第一個byte用LCD_P6x8Str顯示在oled.
理論上應該是很單純...實作如下
1.使用sdk17.首先找出sdk中範例ble_uart,編譯成功後下載測試.可以與手機APP互傳資料.確定原始碼是對的
2.使用周邊例程.測試oled是正確的.意思是說oled.c/oled.h都是對的

3.打開剛剛測過的blr_uart .keil中加入oled.c與oled.h,同時修改include為nrf.h.並在main中挑一個地方執行oled initialize.且顯示圖片.理論上應該要有畫面.修改如下

//211110
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
void OLED_init(void)
{
  int i;
  nrf_gpio_cfg_output(LCD_SCL);
        nrf_gpio_cfg_output(LCD_SDA);
        nrf_gpio_cfg_output(LCD_RST);
        nrf_gpio_cfg_output(LCD_DC);
        nrf_gpio_cfg_output(LCD_CS);
        nrf_gpio_cfg_output(LCD_POWER_EN);
        nrf_gpio_pin_clear(LCD_CS);
        nrf_gpio_pin_set(LCD_POWER_EN);
  LCD_Init(); //oled 初始化  
  for(i=0; i<8; i++)
{
LCD_P16x16Ch(i*16,0,i);  //???示
}
  LCD_P8x16Str(0,2,"LCD");
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/**@brief Application main function.
*/
int main(void)
{
    bool erase_bonds;

    // Initialize.
    uart_init();

    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
  OLED_init();//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    printf("\r\nUART started.\r\n");
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}

三個箭頭顯示增加的部分.但oled完全無顯示.而且手機APP還是可以運作.意思是說ble_uart還是正確的.是否可以請大家給各建議.是什麼樣的問題造成oled無法顯示
我自己的實驗
1.怪的是使用USB LA去量測.訊號一整個奇怪無法理解.完全不像是SPI.不確定是否為準位的問題.
2.難道是start advertising後GPIO設定出錯??
3.我看電路圖.SPI定義在P1.12~P1.14.oled.h中的定義
//#define LCD_SCL  2
//#define LCD_SDA  6
//#define LCD_RST  5
//#define LCD_DC   3
//#define LCD_CS   7
//#define LCD_POWER_EN   4
//#define XLevelL                0x00
//#define XLevelH                0x10
//#define XLevel            ((XLevelH&0x0F)*16+XLevelL)
//#define Max_Column        128
//#define Max_Row                  64
//#define        Brightness        0xCF
//#define X_WIDTH 128
//#define Y_WIDTH 64
顯然的.我抄錯oled.h了,正確的如下
#define LCD_SCL  NRF_GPIO_PIN_MAP(1,15)
#define LCD_SDA  NRF_GPIO_PIN_MAP(1,11)
#define LCD_RST  NRF_GPIO_PIN_MAP(1,12)
#define LCD_DC   NRF_GPIO_PIN_MAP(1,14)
#define LCD_CS   NRF_GPIO_PIN_MAP(1,10)
#define LCD_POWER_EN   NRF_GPIO_PIN_MAP(1,13)

就可以正確顯示
回复

使用道具 举报

Archiver|手机版|小黑屋|Comsenz Inc.   

GMT+8, 2024-4-18 18:01 , Processed in 0.115091 second(s), 30 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表