CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using a PIC to control another PICs MCLR

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Backfire



Joined: 12 Oct 2020
Posts: 46

View user's profile Send private message

Using a PIC to control another PICs MCLR
PostPosted: Fri Sep 15, 2023 7:22 am     Reply with quote

Hello all,
I had a quick question and would value peoples input. I am developing a board that has 4 PIC’s, one device acting as a ‘controller’ (let’s call it the CPU) and three devices that are being controlled (let’s call them ‘Drivers’). The three drivers will each have their MCLR pin connected to a separate GPIO of the CPU, (as well each MCLR net being tied to VCC through a 10K resistor).

My question was how best to code the CPU for toggling the MCLR line of a driver PIC. I only really want to be actively driving the signal when undertaking a reset, otherwise leaving the CPU GPIO floating (un-driven, as the net is electrically pulled to +5V by the external resistor) seems like the best idea.

Would the best implementation be as below, or should I be using the “set_open_drain_b(value)” functions?

Code:

void ResetDriverA(void)
{
    output_drive(PIN_B0);
    output_low(PIN_B0);
    delay_ms(1);
    output_float(PIN_B0);
}


I just want to ensure I’m using the function calls, thanks in advance for peoples input.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Sat Sep 16, 2023 2:53 am     Reply with quote

Assuming the pin is set as standard IO, then the compiler will automatically
enable the tris when a pin is driven, so no need for the 'output_drive'.
What is needed is:

At boot
output_float(PIN_B0);
By default the line will always be floated till it is driven, but this
'makes sure'.

Then in the drive routine:
Code:

void ResetDriverA(void)
{
    output_low(PIN_B0);
    delay_ms(1);
    output_float(PIN_B0);
}


You only need the explicit 'output_drive', if the pin is setup as fixed_io
or fast_io.
Backfire



Joined: 12 Oct 2020
Posts: 46

View user's profile Send private message

PostPosted: Sat Sep 16, 2023 3:06 am     Reply with quote

Amazing!

Many thanks for the advice Ttelmah.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Sep 16, 2023 5:59 am     Reply with quote

as a comment...

stay with using 'standard_IO' and NOT 'fast_IO'.
This way compiler does all the 'details' automatically for you.Iif you use 'fast_io' and you change the hardware pinning and not recode to reassign them, oopsy... 'stuff doesn't work' that used to !!!

In 2 decades of 'playing with PICs', I've only needed fast_io for 2 projects that needed very 'tight' timing to communicate with client's special hardware
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group