[SOLVED] PIC complete discussion for all

Status
Not open for further replies.

romel_emperado

Advanced Member level 2
Joined
Jul 23, 2009
Messages
606
Helped
45
Reputation
132
Reaction score
65
Trophy points
1,318
Location
philippines
Activity points
6,061
guys, Im a starter of PIC microcontroller.

As I check the Hitech c compiler there are fuse bits settings for WDT, FOSC and ETC.. and then when I look to my programmer software (winPICgm and pony prog) the same settings for config bits are present..

the question is, is it the same if I just make a fuse bit settings during programming the device? I mean I will just write code to my compiler without setting a fuse bits. and set it later in my programming software.(winpicgm and ponyprog,Icprog).?
 
Last edited:

thanks ckshivaram!! You're the best!!

I will study first how to set the fuse bits..if you have any useful links pls share.. Im reading also now..
 

Hi,

this is very good tutorial of hitech - C for pic 18
**broken link removed**

---------- Post added at 10:35 ---------- Previous post was at 10:34 ----------

you can get some download books also here
The PIC Tutorial - Free PIC Books
 
I've got this simple code but why there's a warning that is out of date?? what does it mean??



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
#include<pic.h>
 
 
void main()
{
   RA2 = 0;
   while(1)
   {
      RA2 = 1;
   }
}





 

IM using the new version of MPLAB from microchip.. the hex is generated but not funtioning.. i tested it in proteus..
 

thanks.. it's now working.. what's wrong with declaring specific bit like what I did?


this sample code is now working


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
#include<pic.h>
 
 
void main()
{
   TRISB = 0;
   while(1)
   {
      PORTB = 1;
   }
}



---------- Post added at 11:26 ---------- Previous post was at 11:24 ----------

I think I need to declare first TRISB = 0 before I can declare RB2 = 0;

wait I will try..
 

Nothing is wrong, you can use specific bits of a PORT if needed.
If you use TRISB=0;
That means you are setting each bits of TRISB register to 0.
This makes all PORTB bits as output .

If you want to make a single bit say RB0 as output then you can use
TRISB0=0;
or
TRISB=0b11111110;
This details are there in the datasheet.
 
thanks... I think I know a little of using PIC microcontroller... tnx guys... I will practice more..

I tried this code and its working.
.

Code C++ (Qt) - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<pic.h>
 
 
void main()
{
   
   unsigned int x;
   TRISB = 0x02;
   PORTB = 0x02;
   
  
   while(1)
   {
   
      
      RB0 = 1;
      RB5 = 0;
      for(x=0; x<1000; x++);
      RB0 = 0;
      RB5 = 1;
      for(x=0; x<1000; x++);
      
      if(RB1 = 0)
      RB7 = 1;
      else
      RB7 = 0;
      
   }
}

 

yes sorry.. that's typographical error.. hehe

thanks..

---------- Post added at 12:39 ---------- Previous post was at 12:31 ----------

by the way what is the difference if I say

#include"pic.h"
and
#include<pic.h>

the result is the same in the simulation..
 

if you use < > symbol then this file is searched in the complete drive
if you use " " then the header file is searched only in the present working directory......
 
if you use < > symbol then this file is searched in the complete drive
if you use " " then the header file is searched only in the present working directory......

thanks... I see the difference now..



FRIEND,
NO NEED to click 'help' for every post.......okay.:wink:.

what do you mean by clicking help?

---------- Post added at 12:47 ---------- Previous post was at 12:47 ----------

you mean the thanks button?

---------- Post added at 12:49 ---------- Previous post was at 12:47 ----------

I noticed that the fuse bits of HItech C is not working unless you write directly the fuse bits into your code.. . Isn't it?
 

yes... there is no need to click on helpful button.. if you feel the answered has helped you then you can click... that's what vinodstanur means..........
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…