DSPRelated.com
Forums

ADC driver and Interrupts (DSP56F805)

Started by Roger Flor October 18, 2002
Hello!

I am using a DSP56F805 EVM. I am trying to run the ADC. I started by running
the ADC application found in the applications folder that comes with SDK.
When I ran the program, it halts upon entry to main because that is what is
in the debugger settings. The stack pane of the IDE indicates this: archStart
main Everything's fine. I proceed to carefully strip off
the code that I do not need.

When i have stripped off code such that only the following remain:
/*****************************************************************************
*
* Motorola Inc.
* (c) Copyright 2000 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
******************************************************************************
*
* File Name: adcapp.c
*
* Description: ADC device driver
*
* Modules Included:
* < main >
* < ZeroCallBack >
* < CC_CallBack >
* < CC_CallBack_B >
*
*****************************************************************************/

#include "port.h"
#include "arch.h"
#include "io.h"

#include "string.h"

#include "fcntl.h"
#include "assert.h"
#include "adc.h"
#include "led.h"
#include "periph.h"
#include "gpio.h"
#include "types.h" int zeroCnt; /* sero crossing counter */
void ZeroCallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
);

int CCFlag; /* synchronization flag */
int CCFlag_B; /* synchronization flag for ADC B */

void CC_CallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
);
void CC_CallBack_B( adc_eCallbackType type, adc_tSampleMask causedSampleMask
); static const adc_sState sadc = {

/* AnalogChannel = */ ADC_CHANNEL_7,
/* NumSamplesPerScan = */ 2,

/* OffsetRegister = */ FRAC16(0.5),
/* LowLimitRegister = */ 0,
/* HighLimitRegister = */ 0,
/* ZeroCrossing = */ ADC_ZC_ANY,

}; struct ChannelData
{
UWord16 handle;
ssize_t len;
Frac16 Buf[8];
};
struct ChannelData Data0;

/*****************************************************************************
*
* Module: main
*
* Description: ADC test application
*
* Returns: none
*
* Arguments: none
*
* Range Issues:
*
* Special Issues:
*
* Test Method: visual validation
*
*****************************************************************************/
main()
{
Data0.handle = open(BSP_DEVICE_NAME_ADC_0, 0, &sadc );
while(1)
{
Data0.len = read( Data0.handle, Data0.Buf, sizeof(Data0.Buf) );
}
}//end of main() void ZeroCallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
)
{
zeroCnt++;
}
void CC_CallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask )
{
CCFlag = 1;
} The stack pane shows these upon halting at application launch (Debugger
setting: Stop on application launch at Default language entry point):

Stack Pane

0x00002170<Unknown>
configInterruptVector
@DummyFn1
main
When I changed the Debugger setting to: Stop on application launch, User
specified, archStart The stack pane shows the following

archStart
archStart
It seems that interrupts are firing even before the program enters main,
even before the ADC is opened. The ADC was not even started because there
were no calls ioctl(Data0.handle,ADC_START,0). Also, it takes longer for the
application to halt after I hit the debug button. It seems that the code is
wandering in the woods before it comes to its senses. What do you think?

Roger _________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.asp



The key to using the SDK is taking control over what is in the appconfig.h file.  Everthing you put in there controls what happens before the main procedure is called.  Config.c runs out of the ArchStart procedure, which is started from the bootloader.  Config.c starts up the drivers that you have specified in appconfig.h.  Interrupts are enabled when you get to main.c.
 
I you want control of the startup process, you will have to understand how this process works.
 
As far as the ADC goes, it will startup with a default configuration, or as overridden via appconfig.h defines.
 
Reading the appropriate app.notes may be of help also.
 
Jerry.
-----Original Message-----
From: Roger Flor [mailto:a...@hotmail.com]
Sent: Thursday, October 17, 2002 9:03 PM
To: m...@yahoogroups.com
Subject: [motoroladsp] ADC driver and Interrupts (DSP56F805)

Hello!

I am using a DSP56F805 EVM. I am trying to run the ADC. I started by running
the ADC application found in the applications folder that comes with SDK.
When I ran the program, it halts upon entry to main because that is what is
in the debugger settings. The stack pane of the IDE indicates this:archStart
mainEverything's fine. I proceed to carefully strip off
the code that I do not need.

When i have stripped off code such that only the following remain:
/*****************************************************************************
*
* Motorola Inc.
* (c) Copyright 2000 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
******************************************************************************
*
* File Name: adcapp.c
*
* Description: ADC device driver
*
* Modules Included:
*           < main >
*           < ZeroCallBack >
*           < CC_CallBack >
*           < CC_CallBack_B >
*
*****************************************************************************/

#include "port.h"
#include "arch.h"
#include "io.h"

#include "string.h"

#include "fcntl.h"
#include "assert.h"
#include "adc.h"
#include "led.h"
#include "periph.h"
#include "gpio.h"
#include "types.h"int zeroCnt; /* sero crossing counter */
void ZeroCallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
);

int CCFlag;     /* synchronization flag */
int CCFlag_B;   /* synchronization flag for ADC B */

void CC_CallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
);
void CC_CallBack_B( adc_eCallbackType type, adc_tSampleMask causedSampleMask
);static const adc_sState sadc = {

/* AnalogChannel       = */  ADC_CHANNEL_7,
/* NumSamplesPerScan   = */  2,

/* OffsetRegister      = */  FRAC16(0.5),
/* LowLimitRegister    = */  0,
/* HighLimitRegister   = */  0,
/* ZeroCrossing        = */  ADC_ZC_ANY,

};struct ChannelData
{
    UWord16     handle;
    ssize_t     len;
    Frac16      Buf[8];
};
struct ChannelData  Data0;

/*****************************************************************************
*
* Module: main
*
* Description: ADC test application
*
* Returns: none
*
* Arguments: none
*
* Range Issues:
*
* Special Issues:
*
* Test Method: visual validation
*
*****************************************************************************/
main()
{
    Data0.handle  = open(BSP_DEVICE_NAME_ADC_0, 0, &sadc );
    while(1)
    {
        Data0.len = read( Data0.handle, Data0.Buf, sizeof(Data0.Buf) );
    }
}//end of main()void ZeroCallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask
)
{
    zeroCnt++;
}
void CC_CallBack( adc_eCallbackType type, adc_tSampleMask causedSampleMask )
{
    CCFlag = 1;
}The stack pane shows these upon halting at application launch (Debugger
setting: Stop on application launch at Default language entry point):

Stack Pane

0x00002170<Unknown>
configInterruptVector
@DummyFn1
main
When I changed the Debugger setting to: Stop on application launch, User
specified, archStartThe stack pane shows the following

archStart
archStart
It seems that interrupts are firing even before the program enters main,
even before the ADC is opened. The ADC was not even started because there
were no calls ioctl(Data0.handle,ADC_START,0). Also, it takes longer for the
application to halt after I hit the debug button. It seems that the code is
wandering in the woods before it comes to its senses.What do you think?

Roger_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.asp


_____________________________________
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:  m...@yahoogroups.com

To Post:  m...@yahoogroups.com

To Leave: m...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3


">Yahoo! Terms of Service.