This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to generat counter-INT in the RTX-Tiny?

Hello, I am using rtx-tiny and I am having problems in getting interruption of the counter1.

I configure the counter1 to count up to 200 pulses and generate INT, but it only generates the first INT after 32 seconds ... independent for pulses of the 10Hz or 1kHz.

Someone help me, have already set INT along with the tiny?

Thanks,

Fernando

Parents
  • Hi Reinhard,

    I explain better. Excuse my bad English OK.

    I'm using the RTX-Tiny, making the project a speedmeter and odometer for the final university project.
    In calculating the distance using a wheel of 2 meters long, I am using a sensor for a resolution of 2 pulses / meter.

    For resolution of the 100 meters, 2 pulses/meter * 100 meters = 200 pulses.

    Timer1 set up as the counter for counter of pulses by external border, with auto-reload of 8 bits. The T/C1, count 200 pulses at that time it generates an interruption (INT1) for 8051, get an increment for the variable and return to the swith tasks.

    The 8051 is losing interruptions, and can not count the number of interruptions in the correct time, example:
    90 km/h = 1.5 km/minute = 25 meters/second
    (25 meters/second)* 2 pulses/meter = 50 pulses/second = 50 Hz.

    To go 100 meters at 90 km/h, spends 4 seconds, and genereting 50 pulses/second * 4 second = 200 pulses = 1 interrupt = 100 meters.

    The number of pulses at 1 minute = 50 * 60 = 3000 pulses = 3000 / 200 = 15 interrupts

    But, generating with signal generator at pin P3^5 of the 8051, signal of the 50 Hz for 4 seconds, the RTX-Tiny don't count 1 interrupt. And generating 50 Hz for interval of 1 minute, have count 14 interrupts!!!

    The time-ticks for RTX is default.

    Bellow the software

    The result for count interrupt for T/C1 is being placed on the port P2.
    The LED2 blinking for the work the OS.

    #include <REG52.h>
    #include <rtx51tny.h>
    #include <stdio.h>

    //***** DEFINES DAS TASKS
    #define INICIO 0
    #define PISCA 1

    // define pinos
    sbit LED2 = P1^7;

    #define Porta_contagem P2

    static conta_int = 0x00;

    #define MAX_CONT1 255
    #define PULSOS 200

    sbit VEL_IN = P3^5;

    // **** Start Program

    static void trata_timer2 (void) interrupt 3 using 2
    {

    conta_int++; P2 = conta_int;

    }

    void init (void) _task_ INICIO
    {

    unsigned int pulsos = (MAX_CONT1 - PULSOS);

    VEL_IN=1;

    TR1=TF1=0;

    EA=1;

    ES = 0;

    ET1 = 1;

    EX1 = 0;

    ET0 = 1;

    EX0 = 0; TMOD = (TMOD&0xFF)|0x60;

    TCON=0x10;

    TH1 = TL1 = pulsos;

    while (1)

    {

    P0=P1=P2=P3=0XFF;

    P2 = 0X00;

    TR1 = 1;

    os_create_task ( PISCA );

    os_delete_task ( INICIO );

    }

    }

    void pisca (void) _task_ PISCA

    {

    while (1)

    {

    LED2 = ~LED2; os_wait (K_TMO,5000,0);

    }

    }

Reply
  • Hi Reinhard,

    I explain better. Excuse my bad English OK.

    I'm using the RTX-Tiny, making the project a speedmeter and odometer for the final university project.
    In calculating the distance using a wheel of 2 meters long, I am using a sensor for a resolution of 2 pulses / meter.

    For resolution of the 100 meters, 2 pulses/meter * 100 meters = 200 pulses.

    Timer1 set up as the counter for counter of pulses by external border, with auto-reload of 8 bits. The T/C1, count 200 pulses at that time it generates an interruption (INT1) for 8051, get an increment for the variable and return to the swith tasks.

    The 8051 is losing interruptions, and can not count the number of interruptions in the correct time, example:
    90 km/h = 1.5 km/minute = 25 meters/second
    (25 meters/second)* 2 pulses/meter = 50 pulses/second = 50 Hz.

    To go 100 meters at 90 km/h, spends 4 seconds, and genereting 50 pulses/second * 4 second = 200 pulses = 1 interrupt = 100 meters.

    The number of pulses at 1 minute = 50 * 60 = 3000 pulses = 3000 / 200 = 15 interrupts

    But, generating with signal generator at pin P3^5 of the 8051, signal of the 50 Hz for 4 seconds, the RTX-Tiny don't count 1 interrupt. And generating 50 Hz for interval of 1 minute, have count 14 interrupts!!!

    The time-ticks for RTX is default.

    Bellow the software

    The result for count interrupt for T/C1 is being placed on the port P2.
    The LED2 blinking for the work the OS.

    #include <REG52.h>
    #include <rtx51tny.h>
    #include <stdio.h>

    //***** DEFINES DAS TASKS
    #define INICIO 0
    #define PISCA 1

    // define pinos
    sbit LED2 = P1^7;

    #define Porta_contagem P2

    static conta_int = 0x00;

    #define MAX_CONT1 255
    #define PULSOS 200

    sbit VEL_IN = P3^5;

    // **** Start Program

    static void trata_timer2 (void) interrupt 3 using 2
    {

    conta_int++; P2 = conta_int;

    }

    void init (void) _task_ INICIO
    {

    unsigned int pulsos = (MAX_CONT1 - PULSOS);

    VEL_IN=1;

    TR1=TF1=0;

    EA=1;

    ES = 0;

    ET1 = 1;

    EX1 = 0;

    ET0 = 1;

    EX0 = 0; TMOD = (TMOD&0xFF)|0x60;

    TCON=0x10;

    TH1 = TL1 = pulsos;

    while (1)

    {

    P0=P1=P2=P3=0XFF;

    P2 = 0X00;

    TR1 = 1;

    os_create_task ( PISCA );

    os_delete_task ( INICIO );

    }

    }

    void pisca (void) _task_ PISCA

    {

    while (1)

    {

    LED2 = ~LED2; os_wait (K_TMO,5000,0);

    }

    }

Children