Jump to content
Sign in to follow this  
kuyars

Boostc Functions That Are Analagous To C2c Plus

Recommended Posts

Hi, I'm trying to change my program over to make it work with the new BoostC compiler, but I'm really new at this and not quite sure if Im sustituting correctly. For example, in my old program I had this chunk of code:

 

void initialize()
{
   disable_interrupt(GIE);
   clear_wdt();
   set_bit(STATUS, RP0);
   set_tris_a(00010000b);
   set_tris_b(00000000b);
   clear_bit(STATUS, RP0);    
   output_port_a(00001000b);
   output_port_b(11111111b);
}

 

However, since the disable_interrupt() and set_tris_a(), etc functions are not in BoostC (although I could roll my own, but I still wouldnt know how to do it), I substituted the following code for the one above:

 

void initialize()
{
   clear_bit(intcon,GIE);
   clear_wdt();
   set_bit(status, RP0);
   trisa = 0x10;
   trisb = 0x00;
   clear_bit(status, RP0);
   porta = 0x08;
   portb = 0xFF;
}

 

Line for line, does this substitution do the same thing as the original? I'm a little suspicious about the output_port_b() being the same as portb = whatever.

 

Also, I had the following statement in my old program:

 

while (!(input_pin_port_a(4)));

 

which I substituted with:

 

while (!((porta>>3) & 0xFF));

 

Likewise, would this do the same thing? I bitwised shifted it and then used a mask of 1's to filter out the pin that I want...

 

Thanks in advance!! Im just getting started in PIC programming and I'm learning so many new things.

Share this post


Link to post
Share on other sites

I've found that the initialize function seems to work. However, the synchronize function doesnt. I'm not quite sure how to port that function over to BoostC from C2c Plus. Any help would be great.

Share this post


Link to post
Share on other sites
Guest Dave

kuyars,

 

 

while (!(input_pin_port_a(4)));

 

and

 

while (!((porta>>3) & 0xFF));

 

are not equivalent.

The final mask is not correct.

while (!((porta>>3) & 0x01));

 

 

A simpler form is:

while( !(porta & 0x10 ) );

 

Regards

Dave

Share this post


Link to post
Share on other sites

Thank you! That makes perfect sense. I had somehow assumed that all the leading digits would be zeroes, but that may not necessarily have been the case. Your way is certainly better.

Share this post


Link to post
Share on other sites
Guest Dave

kuyars,

 

Bit addressing has been further improved, bits can now have a specified fixed address.

 

You can now do the following

 

bit RA4 @ 0x05.4; // byte address, followed by bit offset

 

or

 

bit RA4 @ 0x44; // or bit address int bits, ( 8 * 0x05 ) + 4

 

 

void myfunc()

{

while ( RA4 );

}

 

 

This generates really effecient code to ;)

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...