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

IS there problem in ccs compiler 4.084

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
[email protected]



Joined: 07 Feb 2012
Posts: 19
Location: pakistan

View user's profile Send private message Send e-mail Yahoo Messenger

IS there problem in ccs compiler 4.084
PostPosted: Fri Feb 17, 2012 6:00 am     Reply with quote

I'm working on I2c protocol, at Proteus it works well but practically with pressing the PIN_D0 or PIN_D1, program goes to in it and continuously printing, Tuned Frequency=%f pll=xxxx
Tthe master side coding is

Code:

#include<18F452.h>
#use delay(clock = 4000000)

#use I2C(MASTER,SLOW, SDA=PIN_C4, SCL=PIN_C3,FORCE_HW,FAST=400000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses NOWDT,NOPROTECT,NOLVP,XT

//BYTE address=0x60;
float tuned_frequency=87.61;


void tuning(float tuned_frequency)
{

 long pll;
 BYTE frequencyH,frequencyL;
 pll=(4*(tuned_frequency*1000+225))/32.768;
 printf("pll=%ld",pll);
 frequencyL=pll;
 frequencyH=pll>>8;


 i2c_start(); 
 
 i2c_write(0xC0);

 i2c_write(frequencyH);
 printf(" data1=%X ",frequencyH);
 i2c_write(FrequencyL);
 printf(" data2=%X ",frequencyL);
 i2c_write(0x0);
 i2c_write(0x10);
 i2c_write(0x0);
 i2c_stop();
}
 
void main (void)
{
    output_d(0x0);
    while(1)
 {
    int1 up,down;
    up=input(PIN_D0);
   if(up==1)
   {
    tuned_frequency=tuned_frequency+.20;
    printf(" Tuned Frequency=%f  ",tuned_frequency);
     output_d(0x0);
     tuning(tuned_frequency);
   }
   down=input(PIN_D1);
   if(down==1)
   {
       tuned_frequency=tuned_frequency-.20;
     printf(" Tuned Frequency=%f  ",tuned_frequency);
    output_d(0x0);
     tuning(tuned_frequency);
   }
  }

}




   
   
   
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

First thought
PostPosted: Tue Feb 21, 2012 2:40 am     Reply with quote

(1) You were using PROTEUS and CCS.
(2) You're now using REAL HARDWARE and CCS.

What changed?
Why should CCS now be faulty when it was OK before?
Why waste time with Proteus?
Why not use REAL hardware from the outset?


Mike
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Second thought
PostPosted: Tue Feb 21, 2012 2:42 am     Reply with quote

How are your switches wired? (Including any resistors. A simple text schematic will do.)

Ignoring what Proteus tells you. What happens when you:-

(1) Press and hold the switch connected to D0?
(2) Release the switch on D0?
(3) Press and hold the switch on D1?
(4) Release the switch on D1?

etc.

I don't have proteus, (correct that, refuse to use Proteus) so can't help there.

Mike
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Feb 21, 2012 8:06 am     Reply with quote

int1 up,down;

Declaring variables within a loop is technically not allowed in C and generally a poor idea.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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