Vectors.c - Fujitsu F2MC-16FX MB2198 Getting Started

Emulator system
Table of Contents

Advertisement

{
TMRLR0 = 0x61A7;
TMCSR0 = 0x181b;
}
void init_ports(void)
{
DDR00 = 0xFF;
PDR00 = 0x00;
}
/*-------------- Main Program -----------------------------------------------*/
void main(void)
{
init_timer();
init_ports();
LED = 0x01;
InitIrqLevels();
__set_il(7);
__EI();
while(1);
}
/*-------------- Interrupt Routine ------------------------------------------*/
__interrupt void Timer_IRQ_Handler(void)
{
TMCSR0_UF = 0;
PDR00 = LED;
LED = LED * 2;
if (LED == 0)
LED = 0x01;
}
The program first initialises the 16-Bit Reload Timer 0, then the LED-Port.
Then the program stops in an endless loop, but every 50 ms the Reload Timer sends an
interrupt request. The MCU then executes the Interrupt Service Routine, which clears the
Interrupt Request and sets a new "position" of the LED.

2.2.2 Vectors.c

Before executing the program, the interrupt definition has to be done. For that, open the file
"vectors.c" and edit the bold and italic entries of the following example:
/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
/* ELIGIBILITY FOR ANY PURPOSES.
/*
(C) Fujitsu Microelectronics Europe GmbH
/*------------------------------------------------------------------------
VECTORS.C
- Interrupt level (priority) setting
- Interrupt vector definition
------------------------------------------------------------------------*/
MCU-AN-300217-E-V10
MB2198 – Getting Started
Chapter 2 Creating the Project
/* set reload value 25000 x 2us => 50ms */
/* prescaler 2,0us at 16 MHz */
/* Set Port00 (LEDs) to Output */
/* Turn off all LEDs */
/* Prepare LED byte for 1st LED */
/* allow all levels */
/* globally enable interrupts */
/* Let Interrupt handler do all things ... */
/* reset underflow interrupt request flag */
/* "move" LED */
/* End reached? */
/* Start up again at position 0 */
- 12 -
© Fujitsu Microelectronics Europe GmbH
*/
*/

Advertisement

Table of Contents
loading

Table of Contents