CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

12F683 not run

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
T0ni0



Joined: 21 Jan 2005
Posts: 11

View user's profile Send private message MSN Messenger

12F683 not run
PostPosted: Fri Jan 21, 2005 5:07 am     Reply with quote

Hi all,

I make a pcb with a 12F675 but not available Flash & change to a 12F683, this is the scheme of this circuit.



When i utilize a 12F675 all run right but with i change to 12F683 not run nothing.

This is the code that i used

Code:
   #include <12F683.h>
   #use delay(clock=8000000)
   #fuses NOWDT,INTRC_IO, CPD, PROTECT, MCLR, NOPUT, NOBROWNOUT, NOIESO, NOFCMEN
   #use rs232(baud=9600,parity=N,xmit=PIN_A2,bits=8)
   #define TRISA1 0x38

void main()
{
   float t1,t2;
   long int n;
    setup_counters(RTCC_INTERNAL,RTCC_DIV_32);
    setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);
   setup_comparator( NC_NC_NC_NC );         // disable comparators
   setup_adc_ports( NO_ANALOGS );            // disable analog inputs
   setup_adc( ADC_OFF );                  // disable ADC
   setup_oscillator(OSC_8MHZ|OSC_NORMAL);      // select 8MHz internal clock
    disable_interrupts(GLOBAL);
    set_tris_a( TRISA1 );                  //
  while (TRUE) {
//captura X*************************************************+
   if (input(PIN_A5))
   {
   while (input(PIN_A5)){}   // espero que baixi nivell
   }
   while (!input(PIN_A5)){}   // espero que pugi nivell
   set_timer1(0x0000);         //activo timer
   set_rtcc(0x00);         //activo timer
   while (input(PIN_A5)){}
   t1=get_rtcc();

   while (!input(PIN_A5)){}
   t2=get_timer1();
   t1=t1*16000;
   t1=t1/t2;
   n=t1;
    printf("#POS:%lu#\r",n);
   output_bit(PIN_A0, !input(PIN_A0));
   delay_ms(1000);
//********************************************************* */
    }
}



Can any help me, thx for advanced
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 21, 2005 2:03 pm     Reply with quote

Post your version of the PCM compiler. It's possible that some
of the CCS functions in your program do not work properly with
your version. Look at the top of the .LST file to see the version.
It will be a number such as 3.191 or 3.216, etc.
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Sat Jan 22, 2005 1:59 am     Reply with quote

I believe you've previously said you were using v3.190 (from Microchip forum). I gave you some code then, but after revising it I modified it as follows:
Code:
/////////////////////////////////////////////////////////////////////////
///   Example program to blink an LED connected to GP1 and GP4
///
/// Fuses: LP,XT,INTRC,HS,NOWDT,WDT,CPD,NOCPD,PROTECT,NOPROTECT,NOMCLR
/// Fuses: MCLR,PUT,NOPUT,RC,EC,RC_IO,INTRC_IO,BROWNOUT,NOBROWNOUT
/// Fuses: BROWNOUT_NOSLP,BROWNOUT_SW,IESO,NOIESO,FCMEN,NOFCMEN
/////////////////////////////////////////////////////////////////////////

//   Preprocessor
#include <12F683.h>
#device ADC=10
#fuses INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD,NOMCLR,NOIESO,NOFCMEN,NOBROWNOUT
#use delay(clock=8000000)
#ROM 0x7FF={0x3400}
#define GP0 PIN_A0
#define GP1 PIN_A1
#define GP2 PIN_A2
#define GP3 PIN_A3
#define GP4 PIN_A4
#define GP5 PIN_A5

#define LED1 GP1
#define LED2 GP4

void init();

//   Main Program
main()
{
   init();
   output_low( GP0 );               // set low
   output_low( GP1 );               // set low
   output_low( GP2 );               // set low
   output_low( GP4 );               // set low
   output_low( GP5 );               // set low
   while ( TRUE )                  // blink LED
   {
      output_high( LED1 );
      output_high( LED2 );
      delay_ms( 500 );            // wait 500ms
      output_low( LED1 );
      output_low( LED2 );
      delay_ms( 500 );            // wait 500ms
   }
}

void init()
{
   set_tris_a( 0b00001000 );         // set GP3 input, all other outputs   
   setup_comparator( NC_NC_NC_NC );   // disable comparators
   setup_adc_ports( NO_ANALOGS );      // disable analog inputs
   setup_adc( ADC_OFF );            // disable A2D
   setup_oscillator( OSC_8MHZ );      // set oscillator to 8MHz

}

The main thing I found is that CCS (v3.184) inserts the following:
Code:
CALL   7FF
BSF    03.5
MOVWF  10

during device initialization. This is probably a carryover from the OSCCAL calibration of the 12F629/675. But the 12F683 does not have an OSCCAL register, the INTOSC is calibrated at the factory. So the call would store the value retrieved from 7FF into OSCTUNE. Unfortunately, the 12F683 does not have anything pre-loaded on that location (since it is not expected to use it), so the programs just gets in a loop and nothing happens. Following a 'workaround' for re-coding the retlw k instruction found on the 12F629/675 (#ROM 0x3FF={0x3480}), I applied the same principle to the 12F683 (#ROM 0x7FF={0x3400}, except an OSCTUNE value of 0x00 means to keep the factory calibration with no deviations).

Try it, it should work.

Can somebody confirm this behavior is fixed on newer versions of PCM?
T0ni0



Joined: 21 Jan 2005
Posts: 11

View user's profile Send private message MSN Messenger

problem solved
PostPosted: Sat Jan 22, 2005 3:48 am     Reply with quote

problem solved !!! Very Happy


THX languer for all (& all people), the problem is the version of compiler

With this version run

setup_oscillator(OSC_8MHZ|OSC_NORMAL); // select 8MHz internal clock

&

setup_oscillator(OSC_8MHZ); // select 8MHz internal clock
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group