DSPRelated.com
Forums

SEM_ipost() problem

Started by lwj July 10, 2004
I am working with the c6712 and I am having problems with semaphores. We
are using one of the McBSPs to implement a UART. Our code is based on
the TI Sample code. In my transmit code I am trying to use a semaphore
to block the task during the EDMA transfer:

void SerialTransmit(char *Bytes, int Count)
{
while (Count)
{
//Wait for any EDMA transfer in progress.
SEM_pend(TxSema, SYS_FOREVER);
SendCount = MIN(Count, EDMA_BUFFER_MAX);
//Configure EDMA and fill the buffer.
FillEdmaBuffer(Bytes, SendCount);
//Kick-off the EDMA transfer.
KickOffEdmaTransfer();
//Update the buffer info.
Bytes += SendCount;
Count -= SendCount;
}
} The relevant parts of the transfer complete ISR are void TransferCompleteISR(void)
{
EDMA_intClear();
EDMA_disableChannle();

//Signal any waiting tasks that the transfer is complete
SEM_ipost(TxSema);
} The problem is that the SEM_ipost() does not seem to change the
semaphore count. Because the count does not change my code blocks on the
SEM_pend....

I googled around a bit and saw some references to wrapping the ISR code
with HWI_disable() and HWI_enable()/HWI_restore() but this does not
change the problem.

I created the semaphore with CCS.

The count is initialized to 1.

The first call to SEM_pend does not seem to change the count either!
However, the second time it does. I am looking at the semaphore value
using the object view in CCS.

Does anyone have any ideas on what I might be doing wrong?

Thanks.



Hi.

I am sucessfully using the SEM_ipost within the context of an ISR, but I believe that you must be using the HWI dispatcher in order for this to be sucessful.
I have not used any HWI_disable or HWI_enable calls either.

Goodluck,
Brett

lwj wrote:
I am working with the c6712 and I am having problems with semaphores.
We
are using one of the McBSPs to implement a UART. Our code is based on
the TI Sample code. In my transmit code I am trying to use a semaphore
to block the task during the EDMA transfer:
void SerialTransmit(char *Bytes, int Count)
{
while (Count)
{
//Wait for any EDMA transfer in progress.
SEM_pend(TxSema, SYS_FOREVER);
SendCount = MIN(Count, EDMA_BUFFER_MAX);
//Configure EDMA and fill the buffer.
FillEdmaBuffer(Bytes, SendCount);
//Kick-off the EDMA transfer.
KickOffEdmaTransfer();
//Update the buffer info.
Bytes += SendCount;
Count -= SendCount;
}
}
The relevant parts of the transfer complete ISR are
void TransferCompleteISR(void)
{
EDMA_intClear();
EDMA_disableChannle();
//Signal any waiting tasks that the transfer is complete
SEM_ipost(TxSema);
}
The problem is that the SEM_ipost() does not seem to change the
semaphore count. Because the count does not change my code blocks on the
SEM_pend....
I googled around a bit and saw some references to wrapping the ISR code
with HWI_disable() and HWI_enable()/HWI_restore() but this does not
change the problem.
I created the semaphore with CCS.
The count is initialized to 1.
The first call to SEM_pend does not seem to change the count either!
However, the second time it does. I am looking at the semaphore value
using the object view in CCS.
Does anyone have any ideas on what I might be doing wrong?
Thanks.
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.
_____________________________________
About this discussion group:
To Join: Send an email to c...@yahoogroups.com
To Post: Send an email to c...@yahoogroups.com
To Leave: Send an email to c...@yahoogroups.com
Archives: http://www.yahoogroups.com/group/c6x
Other Groups: http://www.dsprelated.com
Yahoo! Groups Links


--
Brett Olsen
Senior DSP Design Engineer
Tait Electronics Ltd
535 Wairakei Rd
Christchurch
New Zealand
 
Phone:  (64) (3) 357 0766
Fax:     (64) (3) 359 4632
Email:  
b...@tait.co.nz
Post:     PO Box 1645, Christchurch, NZ


This email, including any attachments, is only for the intended addressee. It is subject to copyright, confidential and may be the subject of legal or other privilege, none of which is waived or lost by reason of this transmission. If the receiver is not the intended addressee, please accept our apologies, notify us by return, delete all copies and perform no other act on the email. Unfortunately, we cannot warrant that the email has not been altered or corrupted during transmission.