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

beginner help

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



Joined: 23 Aug 2007
Posts: 3

View user's profile Send private message

beginner help
PostPosted: Thu Aug 30, 2007 8:05 pm     Reply with quote

i try to simulate the code below using A1 as input if the input of A1 is high the pin A2 will blink once if A1 input is low A3 will blink once

here is the code:

#include <16F84a.h>
#use delay (clock=4000000)

#fuses HS,NOWDT,NOPROTECT
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)

void main()
{

while(1)
{
if ((input(PIN_A1)==1)
{output_high(PIN_A2);
delay_ms(50);
output_low(PIN_A2);
delay_ms(50);
}
else
{
output_high(PIN_A3);
delay_ms(50);
output_low(PIN_A3);
delay_ms(50);

}

}

}

i try to simulate using ISIS lite, but the only blink A3 no matter what input i insert...any idea what's happening ?

i insert the 16f84a, then i insert a logical input (0 or 1), then i run but the A2 condition never met ..why ?

[img]http://www.uploadimages.com/manage/MjM3NjQuMjU4MzI=
[/img]
[img]http://www.uploadimages.com/myalbum/23764[/img]
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Fri Aug 31, 2007 6:21 am     Reply with quote

maybe because pin_a2 is taken by the #use rs232?

Ken
SherpaDoug



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

View user's profile Send private message

PostPosted: Fri Aug 31, 2007 7:19 am     Reply with quote

Ken Johnson wrote:
maybe because pin_a2 is taken by the #use rs232?

Ken


Since the commands for A2 follow the #use rs232 statement they should take control of the pin.

Diehardfans, you should learn touse the "code" button when posting code to this BBS to make reading your code easier.
I would just use if ((input(PIN_A1)) instead of if ((input(PIN_A1)==1).
I haven't used a simulator in many years, so I think it is a simulator problem ;-) I don't see anything wrong with your code.
_________________
The search for better is endless. Instead simply find very good and get the job done.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Fri Aug 31, 2007 4:10 pm     Reply with quote

i ran this on my 16f84a and it worked. you were missing a ) after the if statment coz you had 3 ( and only 2)

i tried something else because it was behaving strangly, like work fine but then stick on one for a little bit then work fine agin but it didnt help.

Code:
#include <16F84a.h>
#use delay (clock=4000000)
#fuses HS,NOWDT,NOPROTECT

void main()
{
while(1)
   {   
   
   if ((input(PIN_A1)==1))
     
      {
         output_high(PIN_A2);
         delay_ms(50);
         output_low(PIN_A2);
         delay_ms(50);
      }     
   else if ((input(PIN_A1)==0))
      {
         output_high(PIN_A3);
         delay_ms(50);
         output_low(PIN_A3);
         delay_ms(50);
      }
   }
}
diehardfans



Joined: 23 Aug 2007
Posts: 3

View user's profile Send private message

PostPosted: Sun Sep 02, 2007 8:32 pm     Reply with quote

thanks for the viewing and the kindness of ur guys....
i will try again....

Keep it up... Laughing
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