Jump to content

Recommended Posts

hi

i want program a pic 16F84 in C with sourceboost.

first i make a basic program to test it.

 

#include <system.h>

 

void main()

{

trisa = 0x00;

trisb = 0x00;

 

porta = 0x0F;

portb = 0xFF;

 

while (1);

 

}

 

when i compile it, i have this warning :

 

unable to successfully crate dealy_us for target with clock freq 4000000 Hz

argument of delay_10us must have a value of 1 or more

 

but in debug mode it work ! the led block is lighting.

now i transfer the program on the pic and ...

nothing hapened, all pin are at 0V ...

 

why ? :huh:

i must control a LCD with this pic for my project... how can i do it if i cant do this basic program ?

 

please help me i m stuck

 

i just buy a new pic and it dont do anything too. :(

Edited by coco343
Link to post
Share on other sites

Your 'main' code after execution goes to nowhere. To fix put an infinite loop at the end of it like in all examples from SourceBoost package. (it's useful to check the samples that work. this way you will make fewer mistakes)

 

Regards,

Pavel

Link to post
Share on other sites
yes i put a while(1) ... it 's not the problem.

i just want set the pin to 1 once

 

but as i said, it work in debugg mode but it dont work when the program is on the pic, all pin are at 0V

 

You need to tell the compiler what clock frequency you are using

 

#pragma CLOCK_FREQ 4000000

 

If you are transfering this to a PIC via a programmer then you need to set all the PICs configuration bits (the fuses). Without this information the PIC oscillator will not be configured, LVP will be enabled by default etc...

 

Here is an example for a PIC16F family member

 

#pragma DATA 0x2007, _HS_OSC & _WDT_OFF

 

Alternatively if you just want a quick and dirty test them most programmers allow you to set the fuses manually.

 

If you are using a bootloader then you do not need to worry about the fuses as you have no control over them, they were set when the bootloader was programmed into the PIC.

 

Regards, Andrew

Link to post
Share on other sites

ok it look like working :huh:

after some test the only change that make it work or not, it s the config word.

by default my programmer set it to 3FFF

and with your code #pragma DATA 0x2007, _HS_OSC & _WDT_OFF , it's set to 3FFA

 

so when i m looking the detail the bit for the watchdog is off but when it s on it work too...

so it's the bit for the FOSC0. when it 's set, it dont work and when it's off, it look like working.

 

what does this bit ?

 

i already program an other pic with the config word set to 3FFF and it 's working normaly ...

 

anyway thank you :D

il will try my LCD now :(

Link to post
Share on other sites
ok it look like working  :huh:

after some test the only change that make it work or not, it s the config word.

by default my programmer set it to 3FFF

and with your code #pragma DATA 0x2007, _HS_OSC & _WDT_OFF , it's set to 3FFA

 

so when i m looking the detail the bit for the watchdog is off but when it s on it work too...

so it's the bit for the FOSC0. when it 's set, it dont work and when it's off, it look like working.

 

what does this bit ?

 

i already program an other pic with the config word set to 3FFF and it 's working normaly ...

 

anyway thank you :D

il will try my LCD now  :(

 

Fuse bits are verry import, u suggest you read the datasheet about them.

 

for example if you enable the watchdog, sure in this case it works. But with another program it wont. This fusebit makes your program to reset everytime after a while. This happens if the bit isnt cleared in your sourcecode.

Link to post
Share on other sites
i know the watch dog thx but what does the FOSC0 ?

where can i find a doc on the fuse ?

 

(welcome fellow newbie)

 

Go to www.microchip.com and download their excellent datasheet, and all else pertinent to your interests.

Examples are another important knowledge stream. There are examples on the SourceBoost site, on Microchip's, and sprinkled over the internet.

Link to post
Share on other sites

ok thanks i finally find it

 

example are fine yes ...

but i had difficult to find a source code for pic in C and not in asm.

and when i find some they are big program. i dont find basic progam like set all pin of the pic or an exemple of fuse.

 

perhaps there is on your site ? so i dont find it, it's not clearly indicate. it ll be usefull to make a tutorial or something like that.

perhaps i m a newbie like you said but i try ! you was newbie too one day !

 

else i m french i not always easy to understand

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...