Jump to content

Recommended Posts

Ok, i finally bought that PIC16F88, and i used following C code to program it:

 

#include <system.h>

//Target PIC16F84 configuration word
#pragma DATA _CONFIG, _PWRTE_OFF & _WDT_OFF & _XT_OSC & _CP_OFF
//Set clock frequency
#pragma CLOCK_FREQ    4000000

void main( void )
{
   //Configure port A
   trisa = 0x00; porta = 0; 
   //Configure port B
   trisb = 0x00; portb = 0;

   while(1)
   {
       porta = 255;
       portb = 255;
   }
}

 

And now i got a problem: everything else works, but Port B pin 3 gives nothing more but 0. Is that PIC broken, is my code wrong, is there something i need to know O_o

Circuit is nothing more than 1k resistor to MCLR, +6v voltage to Vdd, ground to Vss, 4mhz crystal with capacitors to clock inputs, and resistor + led to every port output. It should be correct, 'cause same code+circuit works with PIC16F84

Edited by Louhimo
Link to post
Share on other sites
Ok, i finally bought that PIC16F88, and i used following C code to program it:

 

And now i got a problem: everything else works, but Port B pin 3 gives nothing more but 0. Is that PIC broken, is my code wrong, is there something i need to know O_o

It should be correct, 'cause same code+circuit works with PIC16F84

First, a 16F84 has a different part number than 16F88. This makes me wonder why.

Try reading the data sheet on PortB, there is more to I/O than tris.

RB3 is not available for I/O Unless you ask for it first. :P

keep smiling and keep reading.

Link to post
Share on other sites
Ok, i finally bought that PIC16F88, and i used following C code to program it:

 

And now i got a problem: everything else works, but Port B pin 3 gives nothing more but 0. Is that PIC broken, is my code wrong, is there something i need to know O_o

It should be correct, 'cause same code+circuit works with PIC16F84

First, a 16F84 has a different part number than 16F88. This makes me wonder why.

Try reading the data sheet on PortB, there is more to I/O than tris.

RB3 is not available for I/O Unless you ask for it first. :rolleyes:

keep smiling and keep reading.

 

 

There are somekind of "comparator" modules O_o it seems i need to turn them off somehow, how do i do this with boostc :P Datasheets hardly tell me how to turn them off via boostc?

Link to post
Share on other sites

There are a few ways, the datasheets do tell you how via register settings.

You can also use the pragma variables in boostC, if you look at your chip's

header file they will be near the bottom.

 

Since its not super clear from the datasheet:

Figure 13-1 shows the Comparators OFF block

- CM2:CM0=111 This is in the CMCON Register

Edited by emte
Link to post
Share on other sites
There are a few ways, the datasheets do tell you how via register settings.

You can also use the pragma variables in boostC, if you look at your chip's

header file they will be near the bottom.

 

Since its not super clear from the datasheet:

Figure 13-1 shows the Comparators OFF block

- CM2:CM0=111 This is in the CMCON Register

 

Yeah thanks, found out how to turn off the comparators and now portb pins 0-5 are working fine. How about this:

 

while(1)
{
porta = porta ^ 255;
portb = portb ^ 255;
delay_s(1);
}

 

Leds are blinking only at portb 0-5, whole porta is just 1, nothing blinks, but i guess that is cause i have not disabled ADC right? Trying to find that out now.

But that portb pins 6 and 7 are only 1 and ain't blinking, that's strange, any advices :P ?

 

//EDIT

Yess found out that also portb had 2 analog input channels, and also i found out how to disable analog inputs, everything works, thanks both of you :rolleyes:

Edited by Louhimo
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...
×
×
  • Create New...