|
|
View previous topic :: View next topic |
Author |
Message |
Hiromasa Guest
|
Polaroid 600 Sonar Module ....I have a little problem .. |
Posted: Thu Sep 09, 2004 8:37 pm |
|
|
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 ....
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
|
|
Posted: Thu Sep 09, 2004 9:34 pm |
|
|
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 |
Posted: Fri Sep 10, 2004 1:13 am |
|
|
Hello Haplo...
Firstful....thank you for your help
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... |
|
|
|
|
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
|