This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Serial Port Polling in Timer Interrupt Handler

Hello folks,

I am using Code Composer Studio 3.0 with C6713 Floating Point DSP @ 200 MHz on Windows XP Machine.

My Problem is multifolded.

1. I am using Timer_DEV1 with Timer Control Register's Internal Clock @ CPU/4. I need Interrupt after every 40msec and I am using following formula that i mentioned in Timer Manual. Please Confirm it is correct.

Timer Period Register = ( 40 msec * 50 MHz ) / 2

2. In Timer Interrupt Handler, I want to poll Serial Port for data. Serial Port is polled 50 times before it returns false meaning no data is recieved and Timer Interrupt Handler finishes.

Now, question is should i poll serial port 50 times or not? what is the standard practice?

Should I or should I not,  poll serial port in Timer Interrupt Handler?

 

Please be quick, I am stuck badly coz there are other things that i will ask once I make sure, I am not having problem currently.

Thanx

Adnan

  • Adnan,

    I'm not a C6000 expert, so this might not apply in your case.  However, why are you polling the serial port?  Can't you use an interrupt generated by the serial port itself to tell you when the port has data?  Typically you want your ISR to be as short as possible since it blocks all other activities.  Polling the port 50 times seems like a long time to be in the ISR.

  • adnan khan said:
    1. I am using Timer_DEV1 with Timer Control Register's Internal Clock @ CPU/4. I need Interrupt after every 40msec and I am using following formula that i mentioned in Timer Manual. Please Confirm it is correct.

    Timer Period Register = ( 40 msec * 50 MHz ) / 2

    I am not sure why you divide by 2. As you mentioned the timers operate at CPU/4, so in your case the timer operates at 50MHz. This means that the timer would increment 2 million times before it reached the 40ms time. Your formula is correct except for the /2 - please elaborate as to why you think the divide-by-2 is necessary.

    adnan khan said:
    Now, question is should i poll serial port 50 times or not? what is the standard practice?
    Is the sole purpose of the timer interrupt to simply poll the serial port at a given time? If so then I agree with Tom's point that you are going about this the wrong way. You can either configure the one of the DSP's interrupts to automatically tell you when new data comes in through the serial port, or instead you could offload this to the EDMA engine so that it copies the data into a buffer and interrupts the DSP when the buffer is full.

    I think it would be best if you better explained what exactly you need to do with the Timer and/or Serial Port so we can better suggest how you should implement it.

  • Thanks for Replying. Here is the exact scenerio.

    my system has a standard UART with 128 bytes Rx FIFO. I am recieving a data packet ( 50 bytes) every 40 msec at serial port. After Recieving 100 data packets, I have to process these Packets, which takes almost 450 msec. During this time, my serial port data is not monitored and overflown. So, I am trying to shoot a timer every 40 msec, grab that packet from serial port and put that packet into a Buffer on SDRAM. The problem comes when I am reading the Line valid for serial port, I have observed that i have to poll its status for around 50 times before it let me read the data correctly.

     

    Now I want to ask 2 questions.

    1. Having explained my problem (i.e. saving data of serial port while processing), Am I doing the right approach to solve  the problem ? If not then what is the problem and how it can be corrected?

    2. Even if I am doing it right, its not working (definitely becoz of some reason, that i don't know still). Is there any standard approach for solving such kind of problems.

    Thanx

     

  • By the way I liked the Tim Harrims Idea, that EDMA should be configured such that it copy data from Serial port buffer to SDRAM and interrupt DSP when buffer is full. Is it practical in my case? If Yes, then plz draw some scenerio for my understanding.

    If you stil not have any understanding of my situation, do ask me again.

    Regards

  • adnan khan said:
    Is it practical in my case?

    Absolutely.

    adnan khan said:
    If Yes, then plz draw some scenerio for my understanding.
    The EDMA engine is great in that you can program some registers one time and then let it run. The EDMA will copy n number of bytes from a source address (in this case the serial port) to a destination address (perhaps a buffer in memory). Once the buffer is full the EDMA will generate an interrupt to the CPU indicating the full buffer. The EDMA can then link to a new set of parameters which will copy n number of bytes from a source address (still the serial port) to a new destination (a different buffer in memory) - this method is called ping-pong buffering. Because you have two buffers the EDMA can fill one buffer while the CPU is processing the data in the other buffer.

    This is all pretty well documented in the EDMA User Guide, so please refer to it. If you have trouble getting the EDMA to read the serial port please let us know what specifically you have done and where you are getting stuck.

  • Hello,

    Thanks for help.

    This is my schema of work.

    The situation is a bit different from ping pong buffer scenerio. plz tell me how should i Implement it.

    Also I don't want EDMA to interrupt CPU whenever the transfer is complete. Please Give a detailed answer related to implementation. 

    i really appreciate !!

     

  • It has been a few weeks since your last post here. It seems there is still not enough information for us to help you well without just guessing or sending you to read all the documentation.

    Please let us know if this is still active or not.

  • hello Randy,

    thanx for ur interest. Actually my prob. was solved. 

    so, ya the thread is closed!!