Page 1 of 1
"C for PICmicros" setup_hardware ()
Posted: Thu Feb 24, 2011 4:06 pm
by SHORTCIRCUIT
I'm trying to learn C via the above subject course.
Under analogue fun the statement is used "setup_hardware ()"
I have searched and cannot find any explanation for it, can someone please tell me what it means.
Re: "C for PICmicros" setup_hardware ()
Posted: Thu Feb 24, 2011 4:24 pm
by DavidA
Hello,
Not 100% sure its what you want but under the "Getting Started" header of Lab10 "Analogue Fun" it defines setup_hardware() as:
Code: Select all
void setup_hardware ( void )
{
/* set all of PORTB for output */
set_tris_b ( 0x00 ) ;
/* select A0 for analogue input */
/* and all other bits for */
/* digital I/O */
/* right justified value */
ADCON1 = 0x8E;
/* bits 1-3 of PORTA for output */
/* using bit 0 for analogue */
/* input */
set_tris_a ( 0xf1 ) ;
}
Re: "C for PICmicros" setup_hardware ()
Posted: Thu Feb 24, 2011 5:08 pm
by SHORTCIRCUIT
Hi David
Thank you for the quick reply.
Actually I was asking about the statement under the "Automatic Night Light" section of that same Lab, but because you pointed me there I think I now understand.
Is that statement calling the sub-routine "void setup_hardware (void)" which was written in the "Getting Started" section, to setup the Pic hardware registers?
Please confirm, and thanks again
Re: "C for PICmicros" setup_hardware ()
Posted: Fri Feb 25, 2011 8:19 am
by DavidA
Yes, its just a function call to setup_hardware().
If you load up the c file from the exercise you will see that setup_hardware() is written above main() and then called from within main().