Jump to content
Sign in to follow this  
Myrmidon

Quite Few A Few Beginner's Qns

Recommended Posts

Hello all.

 

I'v read the help guides and i'm still a little unsure about some things. I'v migrated from a basic compiler and i generally use the pic16f627 for now.

 

I have my test program ready, just led flashing to get used to the way sourceboost works. Still finding my way with C tho. My programmer can set the fuses at the end before burning onto chip. However, in my program, would i just type:

 

#pragma DATA_CONFIG, _INTRC_OSC_NOCLK & _WDT_OFF & _PWRTE_OFF & _CP_OFF

 

I have the choice of a 37khz timer or 4mhz, i was going for the 4mhz.

 

I tried it in simulator but nothing, the debugger said something about the port a.

 

I basically just copied the sticky led test but modified it, here it is in full.

 

#include <system.h>

 

#pragma CLOCK_FREQ 4000000 //clock at 4mhz

 

//config fuses

 

#pragma DATA_CONFIG, _INTRC_OSC_NOCLK & _WDT_OFF & _PWRTE_OFF & _CP_OFF

 

 

void main ()

 

{

trisb = 0; //port b is output

while( 1 ) //loops forever

{portb.0=1; //pin 0 high

portb.1=0; //pin1 low

portb.2=1; //pin2 high

delay_ms( 1000 ); //pause for 1 second

portb.1=1; //pin1 high

portb.0=0; //low

portb.2=0; //low

}

}

 

 

Can anyone help me out?

 

Cheers.

Share this post


Link to post
Share on other sites

Dear Myrmidon,

 

Notice that after your time delay you set the port B conditions and the program returns to the top...where they are immediately reset to initial condition. If you add another 1 second delay at end of while block, the LED block will behave as you desire (I think)

 

Good Luck and Enjoy

Huck

Share this post


Link to post
Share on other sites

>> the debugger said something about the port a.

It's good to be precise in these matters.

I tried debugging and it worked as you'd expect...

 

>> delay_ms( 1000 );

I'm not certain, but I'd imagine that 1000 is going to be casted to a smaller value. delay_ms takes a char, right? It's 8 bits wide, so the max delay it can produce is 255 ms, I believe. delay_s(1) should do what you want. It delays for a second.

Share this post


Link to post
Share on other sites

>> the debugger said something about the port a.

It's good to be precise in these matters.

I tried debugging and it worked as you'd expect...

 

In the debugger it highlights trisa = 0x00 But then it goes to the end when i click run button and goes green at the while (1).

 

In fact, my program is called led blink.c, but as soon as i run the debugger it comes up with test pic c.c. Which i believe was another name i gave for it?

 

It must be something i'm doing wrong with the ide, because i started a new project, copied and pasted and tired to do it from scratch, but it keeps saying it can't find test pic c.asm and won't build.

 

Where am i going wrong now?

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