|
| View previous topic :: View next topic |
| Author |
Message |
damiencourousse
Joined: 23 Mar 2006 Posts: 13
|
Posted: Thu Jul 19, 2007 7:01 am Post subject: DigitalI/O port |
|
|
Hello,
We would like some explanation concerning the digital outputs on the DSP Toro Baseboard (C67xx), on the JP1 connector (DigitalIo class).
Our main problem is that we cannot control the DigitalI/O port in an interrupt handler function whereas the same code works in the IIMain() function. Please find more explanation below.
We will use the DigitalIO port to control an external peripheral; the whole 32 pins are used in output mode. To set the 32 digital pins to output, the DIO configuration register was set to 0x00FF, according to the user's manual. Then we can write/clear bits independantly or in fields with the DigitalIo::Write/ClearBit() and DigitalIo::Write/ClearField() methods. Is that right ?
The DigitalIO will be controlled by a CLK signal; this should hook an interrupt handler managing the DigitalIO signals.
If we control the DigitalIO port in the IIMain() function, it works fine:
| Code: |
**************
IIMain()
**************
while ( !(*p_host_msg== TD_STOP))
{
*p_dsp_msg=DSP_WAIT_STOP;
if (flag_main){
myDioPtr->SetBit(0);
}
else
{
myDioPtr->ClearBit(0);
}
flag_main = 1 - flag_main;
}
|
If we control the DigitalIO port in the interrupt handler, we can't have it working. In the same function, we generate a wave signal generated by the D/A converters; this works fine and therefore we know that the interrupt is correctly handled by the DSP (function II_EINT7_Handler), whereas in the same handler function the code managing the DIO port has no effect on the output pins.
| Code: |
/******************************************
INT7 Handler
******************************************/
extern "C"
{
#pragma CODE_SECTION(".onchip");
void interrupt II_EINT7_IntHandler()
{
register int i;
static int flag=0;
if (flag){
myDioPtr->SetBit(0);
}
else
{
myDioPtr->ClearBit(0);
}
flag = 1 - flag;
}
} /* END extern "C" */
|
Another question:
Could you also confirm us that the pin's state is updated immediately after calling the Set/ClearBit methods? Could you confirm us that pin values are not latched?
In other words, is the update done instantly after we requested it in the code ? Or is the output clocked ? And if it is clocked, what clocks can be used and how can we configure them ?
Thanks by advance for your help
David MERLIN, Damien Couroussé (ACROE/ICA) |
|
| Back to top |
|
 |
jhenderson Site Admin
Joined: 07 Mar 2006 Posts: 1177 Location: So. Cal. USA
|
Posted: Thu Jul 19, 2007 10:03 am Post subject: flag mishandled |
|
|
I suspect that you are encountering some sort of volatility issue with the flag variable in the ISR. The TI compiler is aggressive about optimizing-out such variables and it mat not be generating the code you expect. Try initializing this variable outside of the ISR function as:
| Code: | | volatile int flag = 0; |
The DigitalIo class does not cache accesses to the port in any way. Writes will take place immediately within the methods of this class. The port itself implements a latch for values read or written. For pins configured as outputs, the latch will hold the last-written state indefinitely. For pins configured as inputs, the latch will hold the state present on the pin when the external clock transitions or a software read operation is performed. _________________ Jim |
|
| Back to top |
|
 |
damiencourousse
Joined: 23 Mar 2006 Posts: 13
|
Posted: Thu Jul 19, 2007 12:46 pm Post subject: |
|
|
Hello Jim,
Thanks for your prompt feedback,
Yes, we known about the volatile "issue".
Actually I should have made my example clearer.
We have tried the following, without using any flag; and this does not work. Here is an example below:
| Code: | /******************************************
INT7 Handler
******************************************/
extern "C"
{
#pragma CODE_SECTION(".onchip");
void interrupt II_EINT7_IntHandler()
{
myDioPtr->SetBit(0);
myDioPtr->ClearBit(0);
}
} /* END extern "C" */ |
The same example works if written in the IIMain() function.
Would it be that the compiler sees that we want to set a bit and that we clear it just after, and therefore decides to do nothing?
Thanks in advance,
Damien |
|
| Back to top |
|
 |
jhenderson Site Admin
Joined: 07 Mar 2006 Posts: 1177 Location: So. Cal. USA
|
Posted: Fri Jul 20, 2007 6:21 am Post subject: DIO in ISR |
|
|
Damien -
Perhaps the problem is more fundamental. Is there any chance that your myDioPtr has not been properly initialized prior to the first invocation of the ISR?
Please tally a volatile variable into this new ISR code to verify that this ISR is still running continuously. Also, note that the code snippet
| Code: | myDioPtr->SetBit(0);
myDioPtr->ClearBit(0);
|
will only create a very short high-going pulse which might be hard to see on the scope. _________________ Jim |
|
| Back to top |
|
 |
damiencourousse
Joined: 23 Mar 2006 Posts: 13
|
Posted: Mon Jul 23, 2007 6:23 am Post subject: DigitalIO in ISR |
|
|
Hello,
Concerning this code snipplet:
| Code: | myDioPtr->SetBit(0);
myDioPtr->ClearBit(0); |
we can actually see the very short high-going pulse that is generated. It lengths between 1 and 1,5 us.
Here is more information about our problem; generally speaking, it seems that the DigitalIO port works only when we use at the same time the Servo class in the IntHandler: in this case, the instance created for the Servo class is linked to the IntHandler function, the sinewave generated on the DAC is correctly generated and if we add a counter, it is normally incremented. And DIO works properly.
When the Servo class is no longer used, the DigitalIO does not work and the counter is not incremented in the IntHandler function: it seems that the the IntHandler() function does not handle the interrupt. However the interrupt (EXT_7) is correctly associated to the IntHandler function in the cdb file associated with the project.
The counter is not incremented in this case.
Normally the interrupt is turned on only when all init procedures are finished.
We would like that the IntHandler function is handled by the CLK signal (either ext or internal using DDS); what did we miss?
Thanks for your help,
Damien & David,
ACROE |
|
| Back to top |
|
 |
jhenderson Site Admin
Joined: 07 Mar 2006 Posts: 1177 Location: So. Cal. USA
|
Posted: Tue Jul 24, 2007 5:00 pm Post subject: Servo base class |
|
|
The Servo base class was specifically designed to perform all necessary initialization of the Toro timebase and analog I/O, plus hook the native interrupt to allow you to easily implement your own servo.
It is not reasonable to expect that the ISR should run by simply configuring EXT_7 in the CDB to point to a particular handler function. The CDB does not handle the myriad details associated with routing the interrupt source to the DSP interrupt pin, configuring the timebase, etc. I don't know why you are trying to avoid use of the ServoBase class, but if you insist on doing so, you will need to scrutinize the functionality embedded within that class and perform that initialization yourself. This will require careful study of the class implementation and the internal register description documentation. _________________ Jim |
|
| Back to top |
|
 |
damiencourousse
Joined: 23 Mar 2006 Posts: 13
|
Posted: Wed Jul 25, 2007 8:10 am Post subject: Re: Servo base class |
|
|
Hello Jim,
| jhenderson wrote: |
It is not reasonable to expect that the ISR should run by simply configuring EXT_7 in the CDB to point to a particular handler function. The CDB does not handle the myriad details associated with routing the interrupt source to the DSP interrupt pin, configuring the timebase, etc. I don't know why you are trying to avoid use of the ServoBase class, but if you insist on doing so, you will need to scrutinize the functionality embedded within that class and perform that initialization yourself. This will require careful study of the class implementation and the internal register description documentation. |
I understand.
Actually, we have one program that will only use the DigitalIO port, and not the ADC/DAC. We would like to drive the DIO modifications by an ext CLK signal (at low frequency: between 100 and 1kHz, but the synchronisation must be as deterministic as possible).
In this case, do you have a simple solution to attach the interrupt to a handler function?
If it is not possible, we will use the Servo class, but I thought there would be a more efficient technique or a direct way. If not, we will continue using the Servo class in this program.
Thanks for your help,
Damien |
|
| Back to top |
|
 |
jhenderson Site Admin
Joined: 07 Mar 2006 Posts: 1177 Location: So. Cal. USA
|
Posted: Wed Jul 25, 2007 1:31 pm Post subject: External DIO clock |
|
|
Unfortunately, the External DIO clock cannot be routed by the FPGA to the DSP external interrupts on the Toro design. However, as a possible work-wround, you might consider running a parallel copy of the EXT CLK signal into J2, the External Interrupt Input. The J2 input is included in the matrix of signals that may be programmatically routed to the DSP interrupts 4..7.
See the attachment for some reference code illustrating routing the external interrupt to DSP interrupt 5 to handle an external low-speed interrupt-driven device. Note: Code fragment extracted from existing application. May not compile as-is. _________________ Jim |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
© Copyright 2006-2008 Innovative Integration
Powered by phpBB © 2001, 2002 phpBB Group
Based on iCGstation v1.0 Template By Ray © 2003, 2004 iOptional
|
|
|