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

Real time Port conflict

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



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

Real time Port conflict
PostPosted: Mon Mar 17, 2008 8:17 am     Reply with quote

Hi. I use PIC 18F2520.Compiler version 3.249
I use a real time clock (RTC)from maxim DS1307. The pin for the data of the clock is PORTC.2 and for the clock pulses is PORTC.1 .

For my project also I use the pin PORTC.3 to send a high-low pulse when a particular event occurs. During the development of the project I noticed that the time or the date or even both of them wasn’t displayed correctly e.g. on the seconds appeared ‘??’or > symbols e.t.c. After a small searching I came up to a conclusion that the pulse on PORTC.1 . was affecting RTC. Also as the frequency of the pulse increased the symbols appeared faster on the display screen . e.g. if the pulse had a frequency of 2KHz then the odd symbols appeared almost instantly .If the pulse had a frequency of 500 Hz then the odd symbols appeared in x seconds ,where x is not a specific time.I changed the port of the pulse to the PORTB.5 Then I saw I didn’t had any problem with the RTC. Is it possible that when the pulse is on the same PORT ,as the data and clock signals of the RTC , can affect it and if yes is there any solution apart from changing the port of the pulse? Thank you
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Real time Port conflict
PostPosted: Mon Mar 17, 2008 10:03 am     Reply with quote

It might be that you are accessing PORTC.3 using code that does not preserve the state of PORTC.1 and PORTC.2. Are you using bit_set(), or are you setting the entire PORTC?

Normally you should be able to use these pins independently without interaction. There is the issue of Read-Modify-Write possibly corrupting the output, but if you use the latch outputs, that should not be a problem.

Robert Scott
Real-Time Specialties
Matro
Guest







PostPosted: Mon Mar 17, 2008 10:07 am     Reply with quote

Could it be a crosstalk problem at the PCB level?

Matro.
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Tue Mar 18, 2008 1:08 am     Reply with quote

I configured the pin for the pulse as

#bit Pulse_Output = PORTC.3

and to turn it on i use Pulse_Output=ON;
and to turn it low
Pulse_Output =OFF;

I don't use bit_Set instruction
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Tue Mar 18, 2008 3:57 am     Reply with quote

I used the latch output LATC.3 instead of the PORTC.3 ,for the pulse ,and it worked. My concern is this know: Is latch output more vulnerable to noise than PORT outpout or not ?
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Tue Mar 18, 2008 9:49 am     Reply with quote

jojos wrote:
I used the latch output LATC.3 instead of the PORTC.3 ,for the pulse ,and it worked. My concern is this know: Is latch output more vulnerable to noise than PORT outpout or not ?


OK, you found the solution. The difference is when you say
Code:

  PORTC.3 = ON;

then the PIC reads all 8 bits from the pins of Port C, sets bit 3, then writes the resulting 8 bits back out to Port C. If there is any noise or load on PORTC.1 or PORTC.2 so that the pin does not read back the same as it was last written, then the read-back will become permanent in the latch.

But when you say
Code:

  LATC.3 = ON;

then the PIC reads all 8 bits of the internal latch, sets bit 3, then writes the result out to the latch. The internal latch is shielded from whatever is going on out there on the pins, so it is more reliable.

Robert Scott
Real-Time Specialties
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 18, 2008 10:00 am     Reply with quote

If you use the CCS pin i/o functions, the compiler automatically does
this for you. It sets the correct TRIS and it uses the Latch register.
Here's the code from the .LST file for the test program shown below:
Code:

... output_high(PIN_C3);
0018:  BCF    TRISC.3
001A:  BSF    LATC.3


Code:
#include <18F2520.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000) 
   
//================================
void main()
{

output_high(PIN_C3);

while(1);     
}
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