Skip to content

psoc6-evaluationkit-062S2 set RTC time failed #8490

@hywing

Description

@hywing

Environment

board : psoc6-evaluationkit-062S2
bsp : PSOC62-IFX-EVAL-KIT 1.1.1
rt-thread : 5.0.1
RT-Thread Studio : 2.2.6

My code


#include <rtthread.h>
#include <rtdevice.h>
#include <time.h>
#include "drv_gpio.h"
#include "drivers/alarm.h"

#define LED_PIN     GET_PIN(0, 1)

#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>

rt_sem_t rtc_init_sem = RT_NULL;

#include <rtdbg.h>

#define RTC_NAME "rtc"

static int uesr_rtc_init(void)
{
    rt_err_t ret = RT_EOK;
    time_t now;
    rt_device_t device = RT_NULL;
    rtc_init_sem = rt_sem_create("rtc init flag", 0, 0);
    if(rtc_init_sem == RT_NULL)
    {
        rt_kprintf("rtc sem init failed!");
        return RT_ERROR;
    }
    device = rt_device_find(RTC_NAME);
    if (!device)
    {
        rt_kprintf("find %s failed!", RTC_NAME);
        return RT_ERROR;
    }
    if(rt_device_open(device, 0) != RT_EOK)
    {
        rt_kprintf("open %s failed!", RTC_NAME);
        return RT_ERROR;
    }
    ret = set_date(2024, 1, 14);
    if (ret != RT_EOK)
    {
        rt_kprintf("set RTC date failed\n");
        return ret;
    }
    ret = set_time(10, 42, 50);
    if (ret != RT_EOK)
    {
        rt_kprintf("set RTC time failed\n");
        return ret;
    }
    rt_sem_release(rtc_init_sem);
    now = time(RT_NULL);
    rt_kprintf("RTC device init success,now time is %s\n", ctime(&now));
    return ret;
}
INIT_APP_EXPORT(uesr_rtc_init);

int main(void)
{
    rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
    for (;;)
    {
        rt_pin_write(LED_PIN, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED_PIN, PIN_LOW);
        rt_thread_mdelay(500);
    }
}

RT-Thread Studio Settings


image


I get an error like this

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions