PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 26, 2007 6:08 pm |
|
|
Quote: | 1- should I put rtos_run command in a do-while loop? |
I scanned the compiler directory for 'rtos_run' with a text search tool.
It shows nine example files that call that function. None of them put
it in a do-while loop. Most of them just stick it in main(), with nothing
after it. However, one of the examples says this:
Code: |
void main ( )
{
// main is the best place to initialize resources the
// rtos is dependent upon.
counter = 0;
rtos_run ( );
// Once the rtos_terminate function has been called,
// rtos_run will return program control back to main.
printf("RTOS has been terminated\n\r");
} |
So if you call the rtos_terminate() function, it will return.
In the example above, CCS then displays a message
and lets the code fall through the closing brace of main().
CCS puts a hidden Sleep instruction there, and because of
that, the PIC will then go to sleep (power down mode).
You have to decide if that's what you want to do.
To prevent the PIC from hitting that Sleep instruction,
it's common to put a while(1); statement at the end of main().
Quote: |
2- setup_adc_ports(AN0_TO_AN1 | VSS_VREF)
when I use the line above, should I apply a Vref+ voltage
on AN3 pin? |
Yes, you have to. Normally, the Vref+ is set to Vdd.
That's the default case. If you don't use Vdd, then you
must supply an external Vref+ voltage to pin AN3. |
|