How to generate interrupt with serial port! - VxWorks

This is a discussion on How to generate interrupt with serial port! - VxWorks ; Hi: I am working on the x86,pcPentium2,now I know exactly how to communicate with serial ports and want to go to research on the serial port,generating interrupt with serial ports.First fo all ,I must declare that I haven't do anything ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to generate interrupt with serial port!

  1. How to generate interrupt with serial port!

    Hi:
    I am working on the x86,pcPentium2,now I know exactly how to
    communicate with serial ports and want to go to research on the serial
    port,generating interrupt with serial ports.First fo all ,I must
    declare that I haven't do anything about the interrupt.
    Below was my first training programme on interrtupt with serial ports:
    #include "stdio.h"
    #include "taskLib.h"
    #include "semLib.h"
    #include "intLib.h"
    #include "D:\Tornado2.2\target\config\pcPentium2\configInum. h"
    #include "D:\Tornado2.2\target\config\pcPentium2\Pc.h"
    #include "arch\i86\ivI86.h"
    LOCAL SEM_ID semId;
    void eventInterrupt();
    void task1();
    void test1()
    {
    semId=semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    intConnect(INUM_TO_IVEC(INT_NUM_COM1),(VOIDFUNCPTR )eventInterrupt,5);
    intEnable(
    taskSpawn("print",100,VX_FP_TASK,4000,(FUNCPTR)task1,0,0,0,0,0,0,0, 0,0,0);
    }
    void task1()
    {
    semTake(semId,WAIT_FOREVER);
    printf("UART Interrupt");
    }
    void eventInterrupt(int a)
    {
    if(a>3)
    semGive(semId);
    else
    return;
    }


    building it successfully,but when I download it,some mistakes
    appearred:
    Errors while downloading
    D:/Tornado2.2/target/proj/Project1/PENTIUM2gnu/test1.o:
    eventInterrupt__Fv

    so,I don't understand what this mistakes means at all,if you know
    something about it , very much appriciate you to tell me !


  2. Re: How to generate interrupt with serial port!

    Hello huangfeihu1,

    huangfeihu1@gmail.com schrieb:
    > building it successfully,but when I download it,some mistakes
    > appearred:
    > Errors while downloading
    > D:/Tornado2.2/target/proj/Project1/PENTIUM2gnu/test1.o:
    > eventInterrupt__Fv


    Maybe you are compiling with C++ compiler. If so, please make the IRQ
    function behave like a normal C-function by
    extern "C {
    }
    wrapper arround the IRQ function.

    Hope it helps.

    --
    BaSystem Martin Raabe
    E: Martin.RaabeB-a-S-y-s-t-e-mde

  3. Re: How to generate interrupt with serial port!

    Thank you,I tried it and found your solution exactly correct.However,I
    can only generate interrupt once,why?what else need I do to generate
    interrupt at any time if I want.thanks!!


  4. Re: How to generate interrupt with serial port!

    "huangfeihu1@gmail.com" wrote:

    >Thank you,I tried it and found your solution exactly correct.However,I
    >can only generate interrupt once,why?what else need I do to generate
    >interrupt at any time if I want.thanks!!


    The code you posted, less the #includes and function prototypes, was:

    >void test1()
    >{
    > semId=semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    > intConnect(INUM_TO_IVEC(INT_NUM_COM1),(VOIDFUNCPTR )eventInterrupt,5);
    > intEnable(
    > taskSpawn("print",100,VX_FP_TASK,4000,(FUNCPTR)task1,0,0,0,0,0,0,0, 0,0,0);
    >}
    >void task1()
    >{
    > semTake(semId,WAIT_FOREVER);
    > printf("UART Interrupt");
    >}
    >void eventInterrupt(int a)
    >{
    > if(a>3)
    > semGive(semId);
    > else
    > return;
    >}


    I see two issues that could lead to the "one-shot" behaviour you describe.

    1) Many devices that generated interrupts require that each interrupt
    be "satisfied" by reading or writing a register in that device before
    subsequent interrupts can be generated. This is typically done in an
    interrupt service routine such as your eventInterrupt() function.

    2) As supplied, your task1() function will return after one occasion of
    executing semTake() and printf(). The task named "print" will
    therefore be deleted and the system will appear to no longer be
    experiencing interrupts. The solution is to wrap semTake() and
    printf() with an infinite loop.

    --
    ================================================== ======================
    Michael Kesti | "And like, one and one don't make
    | two, one and one make one."
    mrkesti at comcast dot net | - The Who, Bargain

+ Reply to Thread