• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#8
新會員
新會員


查看用戶資訊
的確自己把#include "config/default/system/time/sys_time.h"加進宣告中就可以了~
的確是分開宣告,一個在mian.c,兩個在Harmony 產生出來的appxxx.c code內.
這兩個就一個行一個不行,所以才沒想到是header file.

上述兩個產生出來appxxx.c 詫異這麼大?
感謝指導提醒~~

發表於: 2021/10/7 8:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#7
管理員
管理員


查看用戶資訊
這三個HANDLE放在一起宣告, 然後只有第三個錯誤嗎?
感覺上是打錯字或是沒有include sys_time 的 header file.

發表於: 2021/10/6 18:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#6
新會員
新會員


查看用戶資訊
Hi Libra,
感謝你的幫助~
早上改polling mode就可以成功輸出,但還沒細想要怎麼改善.
我正在把Kit 上面的BME280 一起弄在drvier裏面當練習~

遇到怪怪的問題,我在project 裡面做了第三個SYS_TIME_HANDLE
SYS_TIME_HANDLE tmrHandle1;
SYS_TIME_HANDLE tmrHandle2;
SYS_TIME_HANDLE tmrHandle3;

===Complier output========
../src/app_drv_i2c.c:78:1: error: unknown type name 'SYS_TIME_HANDLE'; did you mean 'SYS_TIME_INDEX_0'?
SYS_TIME_HANDLE tmrHandle3;
^~~~~~~~~~~~~~~
=========================


我Clients有開到9,是有其他限制嗎?

發表於: 2021/10/6 16:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#5
管理員
管理員


查看用戶資訊
縮圖

改了SM2002 SPI1 OLED的Lab, 可以使用Driver實現
I2C(OLED+TempSensor+EEPROM+G-sensor), SPI(OLED)
由於I2C OLED原先採用 Two Byte transfer的方式實在是慢,
[0x80] [Cmd Byte 0] , [0x80] [Cmd Byte 1] ... [0x80] [Cmd Byte n] ,
[0xC0] [Data Byte 0], [0xC0] [Data Byte 1], ... [0xC0] [Data Byte n],
建議改成連續Byte的操作方式(詳見SSD1306的Datasheet)
// Bit 7 6 5 4 3 2 1 0
// Co D/C# 0 0 0 0 0 0
// Co : If the Co bit is set as logic “0”, the transmission of the following information will contain data bytes only.
// D/C# : The D/C# bit determines the next data byte is a command or a data.
// If the D/C# bit is set to logic “0”, it defines the following data byte as a command.
// If the D/C# bit is set to logic “1”, it defines the following data byte as a data
[0x00] [Cmd Byte 0] [Cmd Byte 1] ..... [Cmd Byte n]
[0x40] [Data Byte 0] [Data Byte 1] ..... [Data Byte n]

我的I2C Driver Bus Write如下, 還是用Polling方式
避免Driver太晚處理到I2C Transfer Queue,
#define LCM_BUS_CMD  0x00 
#define LCM_BUS_DAT  0x40 
#define LCM_I2C_ADDR 0x3C

void APP_DRV_I2C3_BusWriteuint8_t busvoid *bytessize_t counts )
{
    
uint8_t WriteBuffer[200]; // Max write length might use in this lab.
    
DRV_I2C_TRANSFER_HANDLE I2C3WriteHandle;

    
WriteBuffer[0] = bus;
    
memcpyWriteBuffer+1bytescounts );
    
DRV_I2C_WriteTransferAddI2C3HandleLCM_I2C_ADDRWriteBuffercounts+1, &I2C3WriteHandle );
    while( 
DRV_I2C_TransferStatusGet(I2C3WriteHandle)!=DRV_I2C_TRANSFER_EVENT_COMPLETE );
}

uint8_t OutBuffer[128];
memcpyOutBuffer"Your_Data_Here"128 );
APP_DRV_I2C3_BusWriteLCM_BUS_DAT OutBuffer128 );

Attach file:



jpg  Dual_OLED.jpg (301.67 KB)
67979_615d2b3bc6fcd.jpg 853X480 px

發表於: 2021/10/6 12:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#4
管理員
管理員


查看用戶資訊
由於OLED的Command與Data傳送時, 可能無法等到 Driver 去處理Queue中的 Transfer Request 完成, 建議用 Polling Status 方式來循序完成 OLED 的所有傳送需求,

1. 先拿掉TransferHandler
// DRV_I2C_TransferEventHandlerSet(drv_i2c_oled_handle, drv_i2c_oled_WriteHandler, 0);


2. Write 改成用Polling Status方式來做
void  OLEDWrCmd(uint8_t command)
{
    
OLED_Data[0] = OLED_Command_Mode ;
    
OLED_Data[1] = command ;
    
DRV_I2C_WriteTransferAdddrv_i2c_oled_handleOLED_ADDRESS,
                    
OLED_Data2,&drv_i2c_oled_WriteHandle );
    if(
drv_i2c_oled_WriteHandle == DRV_I2C_TRANSFER_HANDLE_INVALID)
    {
        
app_drv_i2c_oledData.state APP_DRV_I2C_OLED_STATE_ERROR;
        return;
    }     
    
// Polling Transfer Status
    
while( DRV_I2C_TransferStatusGetdrv_i2c_oled_WriteHandle ) !=
                             
DRV_I2C_TRANSFER_EVENT_COMPLETE );
}

void  OLEDWrDat(uint8_t Data)
{
    
OLED_Data[0] = OLED_Data_Mode ;
    
OLED_Data[1] = Data ;
    
DRV_I2C_WriteTransferAdddrv_i2c_oled_handleOLED_ADDRESS,
                    
OLED_Data2,&drv_i2c_oled_WriteHandle );
    if(
drv_i2c_oled_WriteHandle == DRV_I2C_TRANSFER_HANDLE_INVALID)
    {
         
app_drv_i2c_oledData.state APP_DRV_I2C_OLED_STATE_ERROR;
         return;
    }     
    
// Polling Transfer Status
    
while( DRV_I2C_TransferStatusGetdrv_i2c_oled_WriteHandle ) !=
                             
DRV_I2C_TRANSFER_EVENT_COMPLETE );
}

發表於: 2021/10/5 18:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#3
新會員
新會員


查看用戶資訊
練習用Driver改寫完之後,試著跑沒東西出來
我不知道哪邊有問題,是否有先進可以指導一下,我哪邊寫錯.
系統有繼續跑,但OLED畫面沒出來

Attach file:


Link only for registered users

發表於: 2021/10/5 16:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: SAM2002 Lab driver 練習問題(SAMD21G17D)
#2
管理員
管理員


查看用戶資訊
如果你的MP9800 與 I2C OLED使用的是同一組SERCOM時, 則必須要全部採用PLIB寫法或是改用Driver寫法才行, 不能混用, 因為I2C Driver會全權掌控SERCOM PLIB的資源, 如果你自己又用I2C PLIB API去控制SERCOM時, 則I2C Driver會錯亂, 請參考SAM2002 SPI Driver中OLED的作法, 將I2C OLED改用Driver 來實現.

發表於: 2021/9/28 7:40
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


SAM2002 Lab driver 練習問題(SAMD21G17D)
#1
新會員
新會員


查看用戶資訊
我從這個APP-Nano-C21-D21-TW套件開始,自己更換IC (SAMD21G17D)
http://www.microchip.com.tw/modules/tad_link/index.php?link_sn=64

到Lab11 & Lab13 都沒問題,但我想把i2c OLED enable卻出現寫法不同的問題.
i2c OLED 在套件寫法是PILB 用SERCOMx Callback來處理。
//void I2C_EventHandler (uintptr_t context)
//{
// if (SERCOM4_I2C_ErrorGet() == SERCOM_I2C_ERROR_NONE)
// bIsI2C_DONE = true ;
//}
........
// SERCOM4_I2C_CallbackRegister( I2C_EventHandler, 0 ) ;

開啟上述的callback,MP9800 的值就沒有了
關掉才能在Uart 輸出~~

我試過app_drv_i2c.c註冊一個OLED handle來處理好像也不會成功,還是我做錯?
這部分有人試過嗎?或是我應該往哪方向處理?

發表於: 2021/9/24 9:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------