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

pic16f628a/proteus/ccs

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







pic16f628a/proteus/ccs
PostPosted: Thu Apr 03, 2008 11:27 am     Reply with quote

Hi
I have two problems.
One, when I am using the Proteus with the debug I can´t simulate (step by step) the program because I don´t put the initial adress for PC, like the ORG 0x00 in MPLAB.
How to do this in CCS Compiler?
Two, In the Proteus Lay-out I am using switchs. When I play the simulation if I switch other Key it didn't change anything.
I need stop the simulation and play again the simulation for the switch to light one led.
This moment i need switch another key and don´t work. I need stop and start the simulation again. I want to switch the keys and theys light on/off the led without stop/start the simulation.
Thanks.
Guest








PostPosted: Mon Apr 07, 2008 10:18 pm     Reply with quote

Anybody helps?
So, this is my fault.
I Will post the code.
Can I put here the image of proteus?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 5:02 am     Reply with quote

In this forum only a few members use it, did you try to find out some help in a Proteus Forum like this?

http://www.picbasic.org/forum/forumdisplay.php?f=69

Humberto
Guest








PostPosted: Tue Apr 08, 2008 8:11 am     Reply with quote

Humberto
No, sorry.
Ididn't know that site.
I 'll post the Proteus problem there. Is that site is about only picbasic?

Wheterver, the code of two PICs

PIC tx

Quote:

#include <16F628A.h>

#fuses NOWDT,NOPROTECT,PUT,NOLVP,MCLR,INTRC_IO

#use fast_io(a)
#use fast_io(b)
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8)



void main()
{
int i,ch0,ch1,ch2,ch3;
int8 k;
set_tris_a(0b11111111);
set_tris_b(0b10000010);


ch0=input_state(pin_a0);
ch1=input_state(pin_a1);

ch2=input_state(pin_a2);
ch3=input_state(pin_a3);

k=read_eeprom(0x00);


while(1)
{

if(ch0==0)
{
putc('A');
putc('L');
}

else if(ch1==0)
{
putc('A');
putc('X');
}

else if(ch2==0)
{
putc('B');
putc('L');
}

else if (ch3==0)
{
putc('B');
putc('X');
}
}
}



PIC_RX
Quote:

#include <16F628A.h>

#fuses NOWDT,NOPROTECT,PUT,NOLVP,MCLR,INTRC_IO

#use fast_io(a)
#use fast_io(b)
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8)



void main()
{
char rcv1,rcv2;
int8 k;
set_tris_a(0b11111111);
set_tris_b(0b00001010);
output_b(0b000000000);


k=read_eeprom(0x00);


while(1)
{
rcv1=getc();
rcv2=getc();

if(rcv1=='A')
{
switch(rcv2)
{
case 'L':
{
output_low(pin_b5);
output_high(pin_b4);
}
break;
case 'X':
{
output_high(pin_b5);
output_low(pin_b4);
}
break;
}
}
else if(rcv1!='A')
{
switch(rcv2)
{
case 'L':
{
output_high(pin_b6);
output_low(pin_b7);
}
break;
case 'X':
{
output_high(pin_b6);
output_high(pin_b7);
}
break;

}
}
}
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 8:59 am     Reply with quote

In your tx program at startup the keys are read one time and then the values never change again. Move the reading of the input keys into the loop.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Apr 08, 2008 9:07 am     Reply with quote

If there was a $ contributed for every question about RS232 RX and TX this forum would have the revenue of Google. RS232 is asynchronous. This must be repeated several times by anyone coding an RS232 application. Asynchronous means data can arrive at the receiver unsynchronized and it will for your code unless you are doing the synchronization yourself via a protocol or other method of flow control. Chances are if you haven't looked up the meaning of asynchronous then your RX will routine will need to handle asynchronous data. PICC has ways to assist with this one is Kbhit() but it must must must must be called frequently enough to catch the start bit. That means approx half the bit time at the baud rate used. That means the loop that gets back to calling kbhit() must not exceed 1/2 the bit time in execution time. The other way is via the RDA interrupt and a service routine to go with it. Since data can arrive at anytime (asynchronous) the PIC must receive it at any time. That means the PIC must quickly finish what it was doing ( as in the case of the kbhit() loop) or in the case of the interrupt #RDA stop what is was doing. If the PIC has a hardware UART then the interrupt is the better way of dealing with an asynchronous world. The service routine is well written if it has a circular buffer for this not only catches the data but buffers the data
should it arrive in bursts freeing the coder in the main routine to only have to meet the average throughput needs.
alex
Guest







PostPosted: Thu Apr 10, 2008 11:26 pm     Reply with quote

I don´t understand.
I defined the pins of keys in the begin of the program. If the keys, inside the loop, change their state the pic didn´t "see" this changing? Why put the definition of the pins inside the Loop?
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