mlundh wrote on Sunday, December 29, 2013:
Hello,
I am working on a project where i am using the FreeRTOS port provided in Atmel ASF. I run multiple tasks that uses different peripherals.
My plan was to use both TWI peripherals provided on the sam3x processor at the same time. The busses would be used from the same task and the transmissions started right after each other with only the slight delay of setting up the PDC controller between the start of the transmissions. Each of the buses communicates with two identical (except off course for the chip address) ESC units.
That was the background, now to my problem: When i do what i have described above, it only works for a few transmissions and then one of the buses stop working. I used my logic level analyzer to observe the bus behavior, and i can see that the two TWI buses do transmit a few messages simultaneously only to stop working after a short while. If i change the code so that I wait for each transfer to complete before initializing a TWI transfer on the other bus, then everything works well. This, however, requires twice the amount of time to complete all transfers.
I am currently using the following code to initiate a transfer(I am looping through all motors):
portBASE_TYPE twi_ans;
twi_ans = freertos_twi_write_packet_async(motors->motor[i].twi,
&motors->motor[i].twi_data,
motors->motor[i].xtransmit_block_time,
motors->motor[i].twi_notification_semaphore);
if (twi_ans != STATUS_OK)
{
//for (;;)
{
//Error!
toggle_pin(8);
}
}
// TODO fix TWI so this is not needed!
xSemaphoreTake(motors->motor[i].twi_notification_semaphore,
motors->motor[i].xtransmit_block_time);
Here I am waiting for the transmission to complete before doing anything else. I would rather wait for the semaphore associated with the peripheral before trying to start the peripheral again.
This is only a problem since i have a very fast application (500-1000Hz) and i would like to use both buses to reduce communication time.
Has anyone else encountered this problem? Has this anything to do with freeRTOS or the FreeRTOS peripheral drivers provided in ASF or is this a hardware limitation/problem?
Also, I think that there is a problem with the configure_interrupt_controller function in the ASF verstion of FreeRTOS, I think that it is not configured to work with Cortex-M3/Coretx-M4 priority systems. I had to make a change to allow numerically higher values than configMAX_SYSCALL_INTERRUPT_PRIORITY, wich if i have understood things correctly, is a lower priority for these types of processors. Can anyone confirm this?
Regards
Martin Lundh