pic16f876a problem

Hi,
I'm trying to use a pic 16f876a to control an automated gutter cleaner. Unfortunately I can't even compile my code. I was trying to
use sdcc as my compiler, but it doesn't look like it allows for bitwise manipulation and reading of the I/O ports (i.e. PORTBbits.RB2). So I guess I'm looking for a suggestion on a better FREE compiler or a way to do bitwise manipulation of the ports using sdcc. Any suggestions would be greatly appreciated.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Fri, 6 Jun 2008 18:23:37 -0700 (PDT), snipped-for-privacy@gmail.com wrote:

The "Port.BitNum" syntax is a construct that's used by some, but by no means all, embedded compilers to manipulate I/O ports.
You might try a more portable approach, like "Port |= (1 << BitNum)" or "Port &= ~(1 << BitNum)" and so on.
Adjust as necessary for the target processor; I don't recall whether that generation of PICs uses separate registers for "the value of the port is" and "set the value of the port to".
--
Rich Webb Norfolk, VA

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Hi,
Thanks so much for the help. I tried both your comments, but still had problems with MPLAB and a few other compilers. So I've switched my code to the bitwise operators, and have had success with clearing, setting, and toggling bits. But, I still can't figure out how to read an individual bit from the register. Is there an easy way to do this using bitwise operators, or any other means?
Thanks in advance!
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Sun, 8 Jun 2008 12:30:34 -0700 (PDT), snipped-for-privacy@gmail.com wrote:

For instances like if (bit 3 is set in FOO_REG) then do something you can use #define BAR_BIT 3 if (FOO_REG & (1 << BAR_BIT)) or, equivalently if ((FOO_REG & (1 << BAR_BIT)) != 0)
Most compilers will produce identical code for the two constructs but the latter, explicit compare with zero makes it clear to a later reader what the intent is. Be kind to your maintenance programmers; they may be *you*.
You can use a function-like macro to cut down on typing. #define TestBit(reg,bitnum) ((reg) & (1 << (bitnum))) to use if (TestBit(FOO_REG, BAR_BIT) != 0)
--
Rich Webb Norfolk, VA

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Why not using the Microchip software? MPLab for example. Or microC, which is free I think (use google to find, or give me a note via email and I'll send it over)
Cheers, Phil
--
---
Philipp Varley, TU Darmstadt, Mechatronik
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.