iLLD_TC27xC
1.0
|
![]() |
The ASC interface driver provides a default ASCLIN configuration for asynchronous serial communication in 8bit mode, and a set of data transfer routines.
Data transfers are buffered by the hardware based FIFOs, and in addition by software based FIFOs with a configurable size. Incoming and outgoing data is transfered in background from/to the ASCLIN peripheral by interrupt service handlers, which are part of this driver as well. This allows a nonblocking communication without stalling the thread(s) from where data is sent and received.
In the following sections it will be described, how to integrate the driver into the application framework.
Include following header file into your C code:
Declare the ASC handle and the FIFOs as global variables in your C code:
As you can see above, the transfer buffers allocate not only memory for the data itself, but also for FIFO runtime variables. 8 bytes have to be added to ensure a proper circular buffer handling independent from the address to which the buffers have been located.
See also How to define Interrupts?
Define priorities for the Interrrupt handlers. This is normally done in the Ifx_IntPrioDef.h file:
Add the interrupt service routines to your C code. They have to call the ASC interrupt handlers by passing the asc handle:
Finally install the interrupt handlers in your initialisation function:
The module initialisation can be done in the same function. Here an example:
The ASC is ready for use now!
The ASC driver provides simple to use transfer functions, which are blocking.
This means: you can send as much data as you want without taking care for the fill state of the FIFO. If the FIFO is full, the blocking function will wait until the next byte has been transfered to ASCLIN before putting the new byte into the FIFO:
A simple to use receive function is available as well. If no data is in the receive FIFO, it will wait until the next byte has been received:
Streamed transfers are handled faster by the ASC driver and therefore they are recommended whenever a large bulk of data should be sent. Here an example:
Data can be received the following way:
Or alternatively with: