Pumpkin, Inc.

Pumpkin User Forums

help for the coding

If you can't make Salvo do what you want it to do, post it here.

help for the coding

Postby sunny » Wed Apr 16, 2003 5:47 am

aek,

Before I ask the question again. I must thanks for your support even for the free download Salvo Lite version. RTOS is new for me and you are really help to solve the problems. Thanks any way.

After using your suggested cfg file, the program work but another problem is rise. I cannot figure out what is the reason (but 99% not the Salvo bug) so I try to post code here and ask for your help.

The question is here,

code:
void TaskSampling( void )
{
OpenADC( xxx );

for(;;)
{
OS_WaitSem();
OS_DelayTS();

/* other code */
ConvertADC();
While( Busy() );
/* other code */
}
}

void TaskUploadData(void)
{
for(;;)
{
OS_WaitSem();
btoa(); <- data is corrupt after this
}
}


The TaskSampling sample 200 data point and TaskUploadData will run. I need to convert the data in to ASCII to upload through the COM port. I find that after btoa is exec, some of my data is corrupt. A pair of data are being copy to another location (after the first break and show in red from MPLAB SIM), I cannot find the reason how to cause the data to corrupt. I have try to not using Salvo to write this function and show not data corrupt. I cannot find the reason how my bad coding intract with Salvo to cause data corrupt.

The funny things is if I remove the ConverADC OR While( Busy() ), no data corrupt can be seen.

Thanks for help

Sunny

[This message has been edited by aek (edited April 18, 2003).]

sunny
 
Posts: 7
Joined: Mon Mar 24, 2003 12:00 am
Location: hong kong

Re: help for the coding

Postby aek » Fri Apr 18, 2003 8:09 am

Hi Sunny.

Well, for starters, change this:

code:
OSCreateBinSem( LAUNCH_INTEGRATE_P, 1 );
OSSignalBinSem( LAUNCH_INTEGRATE_P );

to this
code:
OSCreateBinSem( LAUNCH_INTEGRATE_P, 1 );

because you don't want TaskIntegrateCTL() creating TaskSampling() twice! This causes a huge problem, because your sequence of tasks will be (check your priorities):

TaskIntegrateCTL() 1x
TaskSampling() 200x + TaskIntegrateCTL() 1x
TaskUploadData() 200x

In other words, TaskIntegrateCTL() will run a second time while TaskSampling() is delayed, all because the initial value of LAUNCH_INTEGRATE_P is 2, not 1.

I suspect this behavior causes you array &data_buf[0] to be written to by TaskSampling() while TaskUploadData() is running ...


------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron