Hello, I have an ch32v303 board.
This is my code:-
/* Global define */
#define TASK1_TASK_PRIO 1
#define TASK1_STK_SIZE 1500
/* Global Variable */
TaskHandle_t Task1Task_Handler;
void GPIO_VOL_REGULATOR_INIT(void) {
GPIO_InitTypeDef GPIO_InitStructure={0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void task1_task(void *pvParameters)
{
static int cnt = 0;
while(1)
{
printf("cnt: %d\r\n", cnt);
wm_lcd_write_num(5, cnt);
printf("Updated\r\n");
vTaskDelay(pdMS_TO_TICKS(5000));
cnt++;
if(cnt >=9){
cnt = 0;
}
}
}
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n",SystemCoreClock);
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
printf("FreeRTOS Kernel Version:%s\r\n",tskKERNEL_VERSION_NUMBER);
GPIO_VOL_REGULATOR_INIT(); //Mandatory
GPIO_Config_Lcd();
wm_config();
xTaskCreate((TaskFunction_t )task1_task,
(const char* )"task1",
(uint16_t )TASK1_STK_SIZE,
(void* )NULL,
(UBaseType_t )TASK1_TASK_PRIO,
(TaskHandle_t* )NULL);
vTaskStartScheduler();
while(1)
{
printf("shouldn't run at here!!\n");
}
}
This is the simple code. This code is displaying the number on the lcd. I have defined wm_lcd_write_num() function in a source file and also related functions in source file. Actually when we passed the lcd segment address and data to wm_lcd_write_num, it displays the data on the lcd segment. But the task is stopping after displaying the 0 digit on the lcd. Means code is stop when compiler reaches at vtaskdelay. When i writes the delay_ms() then it printing the digit on the lcd, but time is unpredictable in case of delay_ms().
In the source file, the functions have delay in the form of delay_ms() or delay_us(). Means i am using these two delays in my source file. Before i was trying the code without freertos, now i am integrating my code on freertos.
Please help me. ?
Why my code is stop on vtaskdelay ().
Is problem to my function?
Because when wm_lcd_write_num is call, it updates the buffer and buffer is update the digit on the lcd, that also defined in a source file.