View previous topic :: View next topic |
Author |
Message |
slyman
Joined: 02 Apr 2015 Posts: 5
|
simulation problem |
Posted: Thu Apr 02, 2015 2:33 pm |
|
|
Hi everyone,
I'm trying to simulate my code in isis. When I simulate it's not work as I expect. My friend send his design, it's working well. I created same design it's still dosen't work.
So please help me. My midterm exam is coming and I don't know what to do
Code: | #include <16f877.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(b)
int i;
#int_ext
void ext_kesmesi()
{
output_high(pin_b1);
delay_ms(1000);
output_low(pin_b1);
delay_ms(3000);
for (i=0;i<10;i++)
{
output_high(pin_b1);
delay_ms(500);
output_low(pin_b1);
delay_ms(500);
}
}
void main()
{
set_tris_b(0x01);
output_b(0x00);
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1);
} |
|
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
|
slyman
Joined: 02 Apr 2015 Posts: 5
|
|
Posted: Thu Apr 02, 2015 3:03 pm |
|
|
I new saw that. I wouldn't ask if it isn't urgent.
and I am sorry |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Thu Apr 02, 2015 3:10 pm |
|
|
Try this:
Code: | #include <16f877.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(b)
void ext_kesmesi()
{
int i; /* Keep your vriable local as much as you can */
output_high(pin_b1);
delay_ms(1000);
output_low(pin_b1);
delay_ms(3000);
for (i=0;i<10;i++)
{
output_high(pin_b1);
delay_ms(500);
output_low(pin_b1);
delay_ms(500);
}
}
void main()
{
while(true)
{
ext_kesmesi() ;
}
} |
|
|
|
slyman
Joined: 02 Apr 2015 Posts: 5
|
|
Posted: Thu Apr 02, 2015 3:20 pm |
|
|
I was making changes in lines. I delete #use fast_io(b) and it worked.
Can anyone explain why ? |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Thu Apr 02, 2015 3:24 pm |
|
|
My bad, The CCS manual stated
Code: | "#USE FAST_IO(port) This directive will configure the I/O port to use the fast method of performing I/O.
The user will be responsible for setting the port direction register using the
set_tris_x() function." |
|
|
|
slyman
Joined: 02 Apr 2015 Posts: 5
|
|
Posted: Thu Apr 02, 2015 3:48 pm |
|
|
Thank you for reply. I will be more careful and follow the rules |
|
|
Sam_40
Joined: 07 Jan 2015 Posts: 127
|
|
Posted: Thu Apr 02, 2015 3:50 pm |
|
|
You are welcome, |
|
|
|