none
写了一个rtc驱动的应用程序,无法设置rtc的值 RRS feed

  • 问题

  • 目前做的是freescale mx27+ce500,rtc是独立的一个实时时钟ic,为sd2068,在应用程序中通过OnBtnWriteRtc进行写
    void CRTC_testDlg::OnBtnWriteRtc()
    {
    // TODO: Add your control notification handler code here
    BOOL bWrite;
    UpdateData(TRUE);
    m_sysTime.wYear = m_uYear;
    m_sysTime.wMonth = m_uMonth;
    m_sysTime.wDay = m_uDay;
    m_sysTime.wHour = m_uHour;
    m_sysTime.wMinute = m_uMin;
    m_sysTime.wSecond = m_uSec;

    if(!SetSystemTime(&m_sysTime))
    MessageBox(TEXT("SetSystemTime is failed! ", NULL, MB_OK);

    if(m_hRTC)
    bWrite = :eviceIoControl(m_hRTC, IOCTL_RTC_WRITE_CURRENT_TIME, &m_sysTime, sizeof(SYSTEMTIME), NULL, 0, NULL,NULL);
    else
    MessageBox(TEXT("m_hRTC is failed! ", NULL, MB_OK);

    if(!bWrite)
    {
    MessageBox(TEXT("bWrite is failed! ", NULL, MB_OK);//每次都返回失败,弹出这个对话框
    // RETAILMSG(1,(TEXT("DeviceIoControl Write is error!"));
    }
    }

    驱动中的相应代码:
    switch(dwCode)
    {
    case RTC_WRITE_CURRENT_TIME:
    st = (SYSTEMTIME*)pBufIn;
                  memset(bBufIn, 0, 6);
    TimestoBCD(st, bBufIn);
    Write_SD2068(hI2C, RTC_I2C_ADDRESS, bBufIn);
    bRet = TRUE;//这地方改成false也不行
    break;
    觉得很奇怪,在驱动的初始化的时候, 对rtc读写都没问题,并且也能设置系统时钟,不知道这问题出在那,麻烦大家给指点指点

    2009年6月11日 13:44

答案