"C for PICmicros" setup_hardware ()

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

"C for PICmicros" setup_hardware ()

Post 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.

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: "C for PICmicros" setup_hardware ()

Post 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 ) ;
}

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Re: "C for PICmicros" setup_hardware ()

Post 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

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: "C for PICmicros" setup_hardware ()

Post 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().

Post Reply