FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2011 Threads] Task Critical blocks USBPosted by Royston Dsouza on October 10, 2011 I am using free RTOS on STM32 hardware which I have designed. There is an STM32F103RG MCU connected to an accelerometer (MMA8415Q), gyroscope(L3G2400D) and USB. The accelerometer is ineterfaced on I2C and Gyroscope on SPI. For the accelerometer and gyroscope routines I use taskENTER_CRITICAL and taskEXIT_CRITICAL during the I2C and SPI access. At the beginning of the program I just read the accelerometer and Gyroscope device ID registers. After this I go ahead and init the USB section for using VCOM.
If I read the accelerometer and Gyrocope registers, the USB is not enumerated by Windows and says Windows cannot recognise device. If i comment out the taskENTER_CRITICAL and taskEXIT_CRITICAL from the accelerometer and Gyroscope routines then the Windows enumerated USB properly.
Can anyone advise on the above problem.
Thanks..
Royston
RE: Task Critical blocks USBPosted by Dave on October 10, 2011 You are asking about application design, not really FreeRTOS, but if the critical section is preventing interrupts that are needed to enumerate the USB then the critical section must be very very long, which is never good. If there is only one device on I2C and one device on SPI, then I doubt a critical section is needed around the whole access, and suspect it will only be needed around the access of any registers that are shared by the two serial buses. You might have better luck using scheduler locking, which will leave interrupts enabled, or making the USB interrupt above configMAX_SYSCALL_INTERRUPT_PRIORITY if it does not make any FreeRTOS API calls.
RE: Task Critical blocks USBPosted by Royston Dsouza on October 10, 2011 Thank you davedoors for your reply.
I have configured the USB priority to be above the SYSCALL priority. Please find code snippet as below.
void USB_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 14; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }
And my FreeRTOS SYSCALL priority is as follows:
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 (lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY 255 #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xa0, or priority 5. */
/* This is the value being used as per the ST library which permits 16 priority values, 0 to 15. This must correspond to the configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY15
I am a bit confused with the priority setting here. Does the FreeRTOS scheduler use priority 15 or does it use priority 5 as stated above.
Thanks in advance
Royston
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|