passer du timer X au timer Z

Postby palla » Wed May 30, 2007 12:00 am

Voici le programme écrit pour que je puisse avoir un timer de 10ms :

void StartTimer(void)
{
/* Set timer X to continuous timer mode clocked by f/8*/

txmr = 0x00;

/* Selected division = X:1/8 */

tcss = 0x01;


/* Preset the timer to generate (20MHz* 1/8) / 250 * 100 = 10ms period.
This value will be updated with A/D value. */
/* Setting Prescaler X register */

prex = 250 - 1;

/* Set an initial value which will be updated with the AD conversion value. */
tx = 100-1;

/* Timer X count start flag = start */
txs = 1;
}

J'utilise un renesas R8C/1B et j'aimerais passer sur le timer Z pour réserver le timer X en mode de mesure de largeur d'impulsion. J'ai donc passer les données précédentes sur le timer Z comme suivant :

void StartTimer(void)
{
/* Set timer Z to continuous timer mode clocked by f/8. */
tzmr = 0x00;
/* Selected division = X:1/8 */
tcss = 0x10;


/* Preset the timer to generate (20MHz* 1/8) / 250 * 100 = 10ms period.
This value will be updated with A/D value. */
/* Setting Prescaler X register */
prez = 250 - 1; /* 250-1*/
/* Set an initial value which will be updated with the AD conversion value. */
//tzpr = 22 - 1; /*25-1*/

/* Timer X count start flag = start */
tzs = 1;
}

Il doit me manquer quelque chose car mes interruptions ne fonctionnent plus comme avant. Je vous remercie de votre aide. pour information suplpémentaire je vous joins quelques fichiers.
palla
 
Posts: 4
Joined: Fri Jan 17, 2014 4:38 pm

Postby nlc » Wed May 30, 2007 12:00 am

Tu as bien crée ta fonction d'interruption timer Z, et sur le bon vecteur ?
nlc
 
Posts: 109
Joined: Fri Jan 17, 2014 4:37 pm

Postby palla » Wed May 30, 2007 12:00 am

voici à quoi ressemble ma fonction d'interruption :

/***********************************************************************************
FILE NAME Interrupts.c
DESCRIPTION This file contain Functions to Configure the interrupt controller
and used interrupts.
Notes:
This file includes a compiler directive #pragma INTERRUPT functionname

This directive instructs the compiler to treat the following function as an interrupt.
The compiler will save all registers used in the function and replace the normal RTS
instruction with an RTE instruction at the end of the function.
The sect30.inc file must be modified to point the appropriate vector at this function.

Copyright : 2006 Renesas Technology Europe Ltd.
Copyright : 2006 Renesas Technology Corporation.
All Rights Reserved
***********************************************************************************/

/***********************************************************************************
Revision History
DD.MM.YYYY OSO-UID Description
07.04.2006 RTE-VNA First Release
***********************************************************************************/

/**********************************************************************************
System Includes
***********************************************************************************/

/**********************************************************************************
User Includes
***********************************************************************************/
/* Following header file provides a structure to access on-chip I/O registers. */
#include "sfr_r81b.h"
/* Following header file provides prototype for interrupt controlling functions. */
#include "Interrupts.h"
#include "rskR8C1Bdef.h"
#include "FlashLEDs.h"
#include "TimerADC.h"

/**********************************************************************************
Global variables
***********************************************************************************/
static unsigned short usCounter = 0x00;

/**********************************************************************************
User Program Code
***********************************************************************************/

/***********************************************************************************
Function Name : ConfigureInterrupts
Description : Configure the interrupts used by the application.
Parameters : none
Return value : none
***********************************************************************************/
void ConfigureInterrupts(void)
{
/* SW1 is connected to INT 0 priority 1 */
int0ic = 0x01;

/* INT0 enable interrupt */
inten = 0x01;

/* SW2 is connected to INT 3 priority 1 */
//int3ic = 0x01;

/* SW3 is connected to KI 1 priority 2 */
/* KI1 input enable */
//ki1en = 1;
/* Key up interrupt enable. */
kupic = 0x02;

/* Timer X priority 4. */
txic = 0x01;

/* Enable interrupts by setting i flag. */
_asm(" FSET I");
}
/***********************************************************************************
End of function ConfigureInterrupts
***********************************************************************************/

/**********************************************************************************
ISR Name : INT_TimerX
Description : Decrements a counter. If the counter is zero, toggle the LEDs and
reload the counter.
Parameters : none
Return value : none
***********************************************************************************/
#pragma INTERRUPT INT_TimerX
void INT_TimerX(void)
{

if (adst == 0 ){

if (ad<2000){
tm0 = 1370-3.5*ad;
tx=210-0.8*ad;}
else
tm0=0;

adst = 1;

}

/* tm0 = 266-1; 80 % */
//tm0 = 533-1;


switch (usCounter) { /* rotor position signal input */
case 0x00: /* case SENSER_DEG0: */
p1 = 0x0a;
p3 = 0x08;
usCounter = 0x01;
break;
case 0x01: /* case SENSER_DEG60: */
p1 = 0x06;
p3 = 0x08;
usCounter = 0x02;
break;
case 0x02: /* case SENSER_DEG120: */
p1 = 0x06;
p3 = 0x10;
usCounter = 0x03;
break;
case 0x03: /* case SENSER_DEG180: */
p1 = 0x0c;
p3 = 0x10;
usCounter = 0x04;
break;
case 0x04: /* case SENSER_DEG240: */
p1 = 0x0c;
p3 = 0x20;
usCounter = 0x05;
break;
case 0x05: /* case SENSER_DEG240: */
p1 = 0x0a;
p3 = 0x20;
//p3 = 0x00;
//p1 = 0x04;
usCounter = 0x00;
break;
default:
break;
}


}
/**********************************************************************************
End of ISR INT_TimerX
***********************************************************************************/

/**********************************************************************************
Switch driven ISRs
***********************************************************************************/

/**********************************************************************************
ISR Name : INT_INT0
Description : Interrupt handler for external interrupt INT0.
SW1 is connected to the INT0 interrupt pin.
If SW1 is pressed, the global variable 'gucKeyPressed' will be set
to 1.
Parameters : none
Return value : none
***********************************************************************************/
#pragma INTERRUPT INT_INT0
void INT_INT0(void)
{
/* tm0 = 266-1; */
}
/**********************************************************************************
End of ISR INT_INT0
***********************************************************************************/

/**********************************************************************************
ISR Name : INT_INT3
Description : Interrupt handler for external interrupt INT3.
SW2 is connected to the INT3 interrupt pin.
If SW2 is pressed, the global variable 'gucKeyPressed' will be set
to 2.
Parameters : none
Return value : none
***********************************************************************************/
#pragma INTERRUPT INT_INT3
void INT_INT3(void)
{
/* tm0 = 533-1; */
}
/**********************************************************************************
End of ISR INT_INT3
***********************************************************************************/

/**********************************************************************************
ISR Name : INT_KEY
Description : Interrupt handler for Key-up interrupt.
SW3 is connected to the KEY-UP interrupt pin
If SW3 is pressed, the global variable 'gucKeyPressed' will be set
to 3.
Parameters : none
Return value : none
***********************************************************************************/
#pragma INTERRUPT INT_KEY
void INT_KEY(void)
{
/* tm0 = 1066-1; */
}
/**********************************************************************************
End of ISR INT_KEY
***********************************************************************************/

Merci.
palla
 
Posts: 4
Joined: Fri Jan 17, 2014 4:38 pm


Return to R8C/13 (01-2006)

Who is online

Users browsing this forum: No registered users and 1 guest