Jump to content


Photo

Pic 12F629

while (1);

4 replies to this topic

#1 Drax

Drax

    Newbrie

  • Members
  • 2 posts

Posted 10 May 2014 - 10:27 AM

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

 

Attached Files



#2 Reynard

Reynard

    Maniac

  • EstablishedMember
  • PipPipPipPip
  • 659 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Archery - target and field

Posted 11 May 2014 - 05:34 PM

Hi Drax,

 

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

 

Cheers

 

Reynard



#3 Drax

Drax

    Newbrie

  • Members
  • 2 posts

Posted 06 June 2014 - 10:19 AM

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



#4 Reynard

Reynard

    Maniac

  • EstablishedMember
  • PipPipPipPip
  • 659 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Archery - target and field

Posted 06 June 2014 - 05:31 PM

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

 



#5 WalterFax

WalterFax

    Newbrie

  • EstablishedMember
  • 5 posts
  • Gender:Male
  • Location:143040
  • Interests:WalterFaxFB

Posted 03 March 2016 - 11:28 AM

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.



Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users