Jump to content

Recommended Posts

Hi,

 

Can you please help me with this c program code.

 

Version of software: SourceBoost IDE version 7.22

 

PIC : 12F629

 

You can see from the attachment , program don't going to infinite loop.

I made mistake but I don't now where?

Can you explain me in my attachment and forward the note.

 

Please.

 

Best regards

 

Drax

 

INTERFON.c

Share this post


Link to post
Share on other sites

Hi Drax,

 

Put your "while(1)" at the beginning of the loop body unless you are performing a "do...while();" loop.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

HI Maniac,

Thanks' lot for helping me with this beginner problems.

I see what I'm doing wrong.

 

I have another problem with load calibration value from 0x3FF register and place that value into OSCCAL register, controller is the same from the first post PIC 12F629.

I used C file (OSCCAL) from example in sourseBoostIDE 7.22, and copy in my project file.

 

 

 

// This sample code was designed for PIC12F629 and shows how to read factory calibration value.
// It will not work unser simulator because simulator doesn't support factory calibration value.

 

#include <system.h>

#ifndef _PIC12F629
#error "This sample code was designed for PIC12F629"
#endif //_PIC12F629

void main()
{
asm //Load Factory Calibration Value Into OSCCAL
{
bsf _status,RP0
call 0x3FF //WHEN I START DEBUGGER PROGRAM RUNING WITH 1,2 LINE , NOT GOING TO 3 LINE AND THAN MASSAGE APPEARS ''HARDWARE STACK OVERFLOW''
movwf _osccal
bcf _status,RP0
}

while(1);
}

 

Best regards,

Drax

Share this post


Link to post
Share on other sites

Hi Drax,

 

When debugging you do not need to calibrate the oscillator as the debugger does not work in real time.

 

Use a conditional compile like this:

#ifndef _DEBUG
	//	Calibrate the internal oscillator.
	asm
	{
		call	0x3ff
		movwf	_osccal
	}
#endif

Use the Debug build option when debugging otherwise use Release for the real thing.

 

The _DEBUG flag is set/reset by the compiler depending on the build.

 

Cheers

 

Reynard

 

Share this post


Link to post
Share on other sites

Also it is preferred to use the .INC file for your pic, then you won't need to enter a register address, just the name.

M.

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum 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...

×