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

Polaroid 600 Sonar Module ....I have a little problem ..

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







Polaroid 600 Sonar Module ....I have a little problem ..
PostPosted: Thu Sep 09, 2004 8:37 pm     Reply with quote

Hello ....
now I have a little bit problem with use Polaroid 600 Sonar Module
It will be work with no probrem on 16F877..
but now I would like to change MCU to 18F452 or 458...

I don't know what I must modefy at my program...

I try a lot of days...but .... Sad

Please help me to check .....

Thank you very much for your help

*********************************
#include <18f452.H>

#device ICD=TRUE
//#use fast_io(E)
#use delay(clock=16000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)


#include <input.c>

#define ECHO PIN_C2
#define INIT PIN_D0
#define BINH PIN_D1
#define BLNK PIN_D2

void check_range(void) ;
void isr_ccp1(void) ;

long echo_time = 0 ;
byte c = 0 ;

#int_ccp1
void isr_ccp1(void)
{
echo_time = CCP_1 ;
}
void check_range(void)
{

set_timer1(0) ;
output_high(INIT) ;
delay_us(900) ;
output_high(BINH) ;
delay_us(100) ;
delay_ms(99) ;
output_low(INIT) ;
delay_us(900) ;
output_low(BINH) ;
delay_us(100) ;
delay_ms(99) ;

printf(" # \%0f cm \r\n", echo_time*0.25*0.0166 ) ;
// CCP_1*Instruction Time*Speed of Sound (cm/us)
}



void main(void)
{
// set_tris_e(0x00) ;

CCP_1 =0 ;

setup_ccp1(CCP_CAPTURE_RE) ; // Configure CCP1 to capture rise
setup_timer_1(T1_INTERNAL) ; // Start timer 1

enable_interrupts(INT_CCP1) ;
enable_interrupts(GLOBAL) ;

output_low(INIT) ; //Assure correct power-up
output_low(BINH) ;
output_low(BLNK) ;

delay_ms(10) ;

while(TRUE)
{
check_range() ;
}
}
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Thu Sep 09, 2004 9:34 pm     Reply with quote

You shouldn't need to make too many changes. Your program, as it is now, looks fine. Add a #fuses statement, something like:

#fuses HS, NOPROTECT, NOWDT, NOOSCSEN, BROWNOUT, BORV20, NOPUT, STVREN, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB, CCP2C1

kantan desuyo! Some of these fuses are important for the correct functionality of your circuit.
Hiromasa
Guest







still have a probrem
PostPosted: Fri Sep 10, 2004 1:13 am     Reply with quote

Hello Haplo...

Firstful....thank you for your help Very Happy

I try to add #fuses like #fuses HS,NOLVP,NOWDT,PUT

but result was same...

now my probrem is can't go correct message from MCU

It's seems ....some thing wrong with CCP and Timer1 setting..

but I rember there are not necessary to change when you move your MCU from 877 to 18f452...
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