Keil Logo

Introduction Modifying the Project Files

STARTUP.S

Modify your STARTUP.S file as follows:

  • Comment out the default DAbt Handler.
  • Add an EXTERN for the DAbt Handler.

An example of the changes is shown below:

;/*********************************************************/
;/* STARTUP.S: Startup file                               */
;/*********************************************************/

...

                EXTERN  DAbt_Handler

Undef_Handler   B       Undef_Handler
SWI_Handler     B       SWI_Handler
PAbt_Handler    B       PAbt_Handler
;DAbt_Handler    B       DAbt_Handler
IRQ_Handler     B       IRQ_Handler
FIQ_Handler     B       FIQ_Handler

main() Function

Add a call to RTA_Init() at the start of your main() function. This should be located before any code other than that required for essential device initialization. Then add the following include statement to this module:

#include "RT_Agent.h"      /* Real-Time Agent definitions */

Note

  • The call to RTA_Init() is not required if your project uses the RTX kernel.

Polled Mode

There are two situations where you may want to use the Real-Time Agent in polled mode:

  • The target hardware does not support interrupt driven mode.
  • You require precise control of real-time performance of the target.

To enable polled mode, select 'Polled Mode' for Hardware Type in the Configuration Wizard. In polled mode, you decide when to send and receive data via the Real-Time Agent. In some real-time critical applications, this can be useful because it provides more deterministic performance; you only give CPU time to the Real-Time Agent when you can.

For the Real-Time Agent to operate in polled mode, you must:

  • Periodically call the RTA_tx_word_ext() and RTA_rx_word_ext() functions from a regular timer interrupt in your application code.
  • Implement the void RTA_irq_enable_ext(void) and void RTA_irq_disable_ext(void) functions. These functions should disable and enable the timer interrupt set up in the step above.

To achieve the maximum data rate possible, call these functions once every 250µs. Calling the functions less often may result in data loss in the form of transmit buffer overruns in the target (µVision will notify you in the Real-Time Agent area of the status bar if data is being lost). Calling the functions more often will not cause harm, but it will not increase the data rate.

A pseudo-code example of the Polled Mode changes is shown below:

void __irq periodic_timer(void) {
   /* Perform periodic tasks   */

   /* User tasks */
   UserTask1();
   UserTask2();
   ...

   /* Transfer Real-Time Agent data */
   RTA_rx_word_ext();
   RTA_tx_word_ext();
}

void RTA_irq_enable_ext(void) {
   ENABLE_PERIODIC_TIMER_IRQ();
}

void RTA_irq_disable_ext(void) {
   DISABLE_PERIODIC_TIMER_IRQ();
}

ATMEL AT91SAM7Sx System Interrupt Configuration

Note

  • This section pertains to ATMEL AT91SAM7Sx MCUs only.

In AT91SAM7Sx microcontrollers, the COMMRX and COMMTX interrupts (ARM DCC interrupts used by the Real-Time Agent) are OR'd with other system interrupts to produce a single input to the System Interrupt (interrupt source 1 on the Advanced Interrupt Controller (AIC)). This means the Real-Time Agent code cannot deal with these interrupts internally, and the user is required to implement calls to the Real-Time Agent interrupt handlers from within their System Interrupt handler.

Also, the System Interrupt must be configured as level triggered, because an edge triggered interrupt will cause interrupts to be missed. If edge triggered, an interrupt would be missed when one source triggers the System Interrupt, and between this time and when the interrupt is acknowledged, another source triggers. When this happens, the edge will be missed.

An example of the System Interrupt configured with the Real-Time Agent and Periodic Interval Timer (PIT) is shown below:

#include "RT_Agent.h"

__irq void system_int (void) {             /* System Interrupt Handler */
  volatile AT91S_PITC * pPIT = AT91C_BASE_PITC;

  // Process COMMRX interrupt if any (Real-Time Agent)
  if (*AT91C_DBGU_CSR & *AT91C_DBGU_IMR & AT91C_US_COMM_RX) {
    RTA_rx_word_ext();
  }

  // Process COMMTX interrupt if any (Real-Time Agent)
  if (*AT91C_DBGU_CSR & *AT91C_DBGU_IMR & AT91C_US_COMM_TX) {
    RTA_tx_word_ext();
  }

  // Process PIT interrupt if any
  if (pPIT->PITC_PISR & AT91C_PITC_PITS) { /* Check PIT Interrupt */

    /* Perform timer related task interrupt task */

    pPIT->PITC_PIVR;                       /* Ack PIT Interrupt */
  }

  *AT91C_AIC_EOICR = 0;                    /* Signal interrupt end to AIC */
}

void init_system_int (void) {              /* Setup System Interrupt */
  AT91S_AIC * pAIC = AT91C_BASE_AIC;

  pAIC->AIC_SMR[AT91C_ID_SYS] = AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | 7;
  pAIC->AIC_SVR[AT91C_ID_SYS] = (unsigned long) system_int;
  pAIC->AIC_IECR = (1 << AT91C_ID_SYS);


  *AT91C_PITC_PIMR = AT91C_PITC_PITIEN |   /* PIT Interrupt Enable */
                     AT91C_PITC_PITEN  |   /* PIT Enable */
                     PIV;                  /* Periodic Interval Value */


}

A working example for the Atmel AT91SAM7S-EK development board can be found in C:\KEIL\ARM\RT Agent\AT91SAM7S-EK\.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.