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 support@ccsinfo.com

12F675 Simple Adc to rs232 and I'm getting "out of ROM

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



Joined: 13 Oct 2007
Posts: 53
Location: Texas

View user's profile Send private message Visit poster's website Yahoo Messenger

12F675 Simple Adc to rs232 and I'm getting "out of ROM
PostPosted: Thu Apr 02, 2009 9:50 pm     Reply with quote

Hello everyone,
Haven't been here in a while. I've been looking through the boards but have not found anything. This is a weird error, my code is so small.

Im getting the error "out of ROM, A segment or the program is too large"

When i comment out the " printf("%f",total); " it works fine.

this is my .c I tried to reduce it as much as possible
Code:
#include "C:\Program Files (x86)\PICC\Drivers\12f675test.h"
  #include <float.h>
  //#include <math.h>
  #include <stdio.h>
  //#include <string.h>

   // adc variables
   int i =0;
   int adc_value;
   float volts;
   //float diff = 30.4; // scale it down  ?
   float total = 0;
   //float temp = 0; // chop off the .xx

void main()
{

   setup_adc_ports(sAN0|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_8);
   set_adc_channel(0);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

     

   while(1){
         //temp=0;
         total = 0;
         for (i=0; i<20; i++)
         {
            adc_value = read_adc();
            total += (float)(adc_value * 5)/255;
            delay_us(100);
         }
         total = ((total/20)*100);
         
         delay_ms(500);
         printf("%f",total);
   }

}



my .h file
Code:
#include <12F675.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,HS, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT
#use rs232(baud=9600,parity=N,xmit=PIN_A2,bits=8)


Im just transmitting a analogue value on pin a0 to the computer using rs232, all thats working fine, just dont know what this error means. Anyway thats why there is no receive pin setup.

thanks for reading this, and thanks for your time.
_________________
Smart people know how stupid they are.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 02, 2009 10:13 pm     Reply with quote

Commenting out the printf statement allows it to compile.
Your existing code without the printf, uses up almost all of the PIC (88%).
This PIC only has 1024 ROM words. This PIC is really too small to
use floating point, except in a limited way.
Quote:
CCS PCM C Compiler, Version 4.090, xxxxx 02-Apr-09 20:59

Filename: 12F675_Test.lst

ROM used: 897 words (88%)
Largest free fragment is 127
RAM used: 19 (30%) at main() level
33 (52%) worst case
Stack: 1 locations

If you must use an 8-pin 12F PIC, I suggest that you use the 12F683.
It has 2048 ROM words available and it has an A/D converter.
zonemikel



Joined: 13 Oct 2007
Posts: 53
Location: Texas

View user's profile Send private message Visit poster's website Yahoo Messenger

PostPosted: Fri Apr 03, 2009 1:24 pm     Reply with quote

Thanks, I'll be sure to look at that summary from now on when i compile. I do have a 12f683 laying around I might use that or just send the adc_value directly to the computer and let it do the averaging.

thanks again for your time.
_________________
Smart people know how stupid they are.
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