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

12C671 OTP vs 12F675 Flash

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



Joined: 20 Dec 2003
Posts: 1

View user's profile Send private message

12C671 OTP vs 12F675 Flash
PostPosted: Sat Dec 20, 2003 4:54 pm     Reply with quote

I'm having trouble making the 12C671 function properly, while the same code works fine with the 12F675 Flash part. I include either the Flash or the OTP info and comment out the other one to select which part to program. The programmer and the compiler both use the 12C671.h file for 12C671 and the 12LC671 which is what we are using.

I don't think that there is a problem with the Fuses but maybe there is. The two lines below are the possible fuses for the part.

//////// Fuses: LP,XT,HS,RC,NOWDT,WDT,NOPUT,PUT,PROTECT,PROTECT_75%
//////// Fuses: PROTECT_50%,NOPROTECT,MCLR,INTRC,NOMCLR,INTRC_IO,RC_IO

The part is programming with no errors and that when you power it up you can't get any output from the part. You can see that the part is running because the clock out signal is at 1 MHz.

Here is the .c file
Code:


// Note: use this include for PIC12C671 parts(note that these are commented out if programming a Flash part):
#include <12C671.h>
#use delay(clock=4000000)
#fuses INTRC,NOMCLR,NOPROTECT,NOPUT,NOWDT

// Note: use these include lines for programming PIC12F675 Flash parts: (note that these are commented out if programming an OTP part)
//#include <12F675.h>
//#use delay(clock=4000000)
//#fuses INTRC,NOWDT,NOMCLR,NOPROTECT,NOPUT,NOCPD,NOBROWNOUT


//
//compiled with PCW C Compiler  Revision 1.3
//


int x = 0;
int y;
int rtcc_var = 216;
int dec_count = 0;
long total = 0;
long zero_point = 0;
long high_point = 0;
long count, half;
long lastcount = 0;
long avg;
int lookup;
int timer_value = 0;
short decrease = 0;

BYTE CONST table_one [256] =  {0,0,1,1,2,2,3,3,4,4,
                         /*10*/5,5,6,6,7,7,8,8,9,9,
                         /*20*/10,11,12,13,14,15,16,17,18,19,/*30 */20,20,20,21,21,21,22,22,22,23,
                         /*40*/23,23,24,24,25,25,26,26,27,27,/*50 */28,28,29,29,30,30,31,31,32,32,
                         /*60*/33,34,34,35,36,36,37,37,38,38,/*70 */39,39,40,40,41,42,42,43,43,44,
                         /*80*/45,45,46,46,47,48,48,49,49,49,/*90 */50,50,50,51,51,52,52,53,53,54,
                        /*100*/54,55,55,56,56,57,57,58,58,59,/*110*/59,60,60,60,61,61,62,62,63,63,
                        /*120*/64,64,65,65,66,66,67,67,68,68,/*130*/69,69,70,70,70,71,71,72,72,73,
                        /*140*/73,74,74,75,75,76,76,77,77,78,/*150*/78,79,79,80,80,80,80,80,81,81,
                        /*160*/81,81,81,82,82,82,82,82,83,83,/*170*/83,83,83,84,84,84,84,84,85,85,
                        /*180*/85,85,85,86,86,86,86,86,87,87,/*190*/87,87,87,88,88,88,88,88,88,88,
                        /*200*/89,89,89,89,89,89,89,89,90,90,/*210*/90,90,90,91,91,91,92,92,93,93,
                        /*220*/93,94,94,95,95,95,96,96,97,97,/*230*/98,98,98,99,99,100,100,100,100,100,
                        /*240*/100,100,100,100,100,100,100,100,100,100,/*250*/100,100,100,100,100,100};


#priority EXT,RTCC
#int_RTCC
RTCC_isr() {
   count++;
   set_rtcc(rtcc_var);
}

#int_EXT
EXT_isr() {  // got here from hardware interrupt from the Novatek processor
  if (bit_test(timer_value,x)) { // test bit x of timer_value
    output_high(PIN_A0); //if bit x=1 then output high to Novatek processor
  } else {
    output_low(PIN_A0);  //else if bit x=0 then output low to Novtek processor
  }
  ++x;  // increment x
  if (x==8) { // if x=8 then data has been sent
    x = 0;  // set x=0
  }
}


void main() {
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_1);

   // only needed for flash parts.
   //setup_comparator(NC_NC_NC_NC);

   set_tris_a(0b00000110);
   port_a_pullups(true);

   enable_interrupts(global);
   ext_int_edge(L_TO_H);
   output_low(PIN_A0);
   delay_ms(500);

  // get zero point

   if (!input(PIN_A1)) { // if input is low wait for high
      while (!input(PIN_A1)) {}
   } else { // if input is high wait for low and then wait until it flips high
      while (input(PIN_A1)) {}
      while (!input(PIN_A1)) {}
   }
   count = 0;
   set_rtcc(rtcc_var); // restart the counting process

   enable_interrupts(INT_RTCC);

   while (input(PIN_A1)) {}

   disable_interrupts(INT_RTCC);

   zero_point = count;
   zero_point = (zero_point - 7) * 2;

   enable_interrupts(INT_EXT);

   while (true) { // loop forever
      while (x==0) {  // if external interrupt has triggered (x>0) wait until data is sent and x=0 again
         // we don't want the data being sent to change in the middle of sending it
         avg = 0;
         if (!input(PIN_A1)) { // if input is low, wait for high
            while (!input(PIN_A1)) {}
         } else { // now that input is high, wait for low, then high again
            while (input(PIN_A1)) {}
            while (!input(PIN_A1)) {}
         }
         count = 0;
         set_rtcc(rtcc_var);
         enable_interrupts(INT_RTCC);
         while (input(PIN_A1)) {     // while input is high start counter
            if (x > 0) {break;}
         }
         disable_interrupts(INT_RTCC);
         if (x > 0) {break;}

         count = count * 2;
         avg = (count + lastcount) / 2;

         high_point = zero_point - 256;

         if (avg >= zero_point) {
            timer_value = 0;
         } else if (avg <= high_point) {
            timer_value = 100;
         } else {
            lookup = zero_point - avg;  // now get the table output value
            timer_value = table_one [lookup];
         }

         lastcount = count; // keep old count for average

       } // while x==0

    } // while true

} // main

Code:
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

Helping on project
PostPosted: Mon Dec 22, 2003 10:43 am     Reply with quote

I am working on this project with TJDesign. We think that the problem either lies in the Fuses or the setup of the part. The other thing that I've seen a few posts on is that the file names are fairly long and we may need to put the project in a directory closer to the root.

If someone can pick something out that looks wrong in the fuses or part setup that would be great Very Happy . We've been through it several times and tried different combinations of fuses and various other things with no luck Mad . The part appears to be working, because the clock out is running at 1 MHz, but we just can't get any output from the part.

We don't want to try to program anymore parts without getting a fresh pair of eyes to look over the code and see if something stand out. We've already gone through a half dozen parts and that starts adding up after a while.

Any help, thoughts or ideas would be great Smile Smile .

Thanks,

jspencer
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 22, 2003 11:22 am     Reply with quote

Quote:
//compiled with PCW C Compiler Revision 1.3

What's the version of your compiler ? The version given above
is likely the IDE version. The compiler version can be found at
the top of the .LST file.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Dec 22, 2003 1:36 pm     Reply with quote

Have checked the code and it seems Ok. Regarding the #fuses configurations, what I would do to test it is to toggle a pin and watch it with a scope if the program pass by the points I expected, these is a good aproach to the real world.

Quote:

The part appears to be working, because the clock out is running at 1 MHz, but we just can't get any output from the part.


This do not warranty that the program is running, just a sample of the clock activity.

regards,

Humberto
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

Compiler Version
PostPosted: Mon Dec 22, 2003 5:32 pm     Reply with quote

The Compiler Version is:

PCW V3.176
IDE V3.24

I may have found an issue in my code. I was working on it today just using a 12F675 and on an older part the program worked fine. On new parts(3) that we just purchased, it wouldn't work. I stripped the code down and just did some basic toggling of the output and it worked fine on the new parts. So I just need to add sections of the code back in until it quits working and hopefully I'll find what I'm looking for.
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