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

PWM and LATx

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







PWM and LATx
PostPosted: Mon Aug 02, 2004 10:33 am     Reply with quote

If one uses the CCP, then the PWM pin is RC2, i think.
If one uses the ECCP, then the PWM pins involved are RD4-RD7

My question is this...

If I write to LATx (x is the port with the PWM pin clocking up and and down, so in this case either LATC for CCP or LATD for ECCP), will the PWM transitions continuously update LATC (or LATD)?

For example,

Step 1: Write any value to LATC.
Step 2: Allow a few PWM transitions to pass by.
Step 3. Read LATC.

Will the value of LATC at RC2 (the PWM pin) preserve the value I wrote to it in Step 1, despite the transitions it goes through?

I need to know this because i intend to preload the LATx register, turn off the PWM module, and configuring the PWM pin(s) as GPIO outputs, and hope that what I preloaded is what I get on those pins, without glitches.

-Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 02, 2004 4:51 pm     Reply with quote

Quote:

I need to know this because i intend to preload the LATx register, turn off
the PWM module, and configuring the PWM pin(s) as GPIO outputs, and
hope that what I preloaded is what I get on those pins, without glitches.

The block diagrams for Port C and Port D (for the 18F4220, for example)
show a 2:1 mux after the latch. It selects between the PWM signal
and the latch signal. The PWM signal does not go through the latch.

So I think the answer to your question is yes, it will do what you want.
valemike
Guest







Description of Read-Modify-Write
PostPosted: Tue Aug 03, 2004 8:04 am     Reply with quote

Thanks PCM,

I also looked at the diagrams in the manual, and you're right. I also figured the latch registers are not affected by PWM transitions because their logic diagrams were not connected, but I wasn't sure if the diagram was oversimplified which would lead to wrong assumptions. I figured i'd ask around both in this forum and to Microchip's tech support team.

So for our reference...

Microchip's tech support answer (tech.support_at_microchip.com) said in an email that I read this morning:

Quote:
Mike, Whenever, you disable the ECCP control of the pins, then the state of the PORTD output latch will be driven out on those pins designated as outputs. So, if you have preloaded a given state into the PORT register, then that will be the state of the output pins when the ECCP module control is released. Writing to the the PORTD or LATD register really won't matter if you are writing the entire register. If you are performing bit operations (i.e. bcf or bsf instructions), then the R/M/W issue will come into affect. When you perform a bit operation on the PORT register, the entire PORT register is read, then bit operation is performed, and then the entire PORT register is rewritten. When the PORT register is read, it is the actual logic state on the pin is what is read and not the output latch value, so if you have a situation in which there is a load on a pin that might cause the logic state written to the pin to disagree with the actual logic state on the pin, then you will see the output logic level change when the whole port register is rewritten. If you write to the LAT register, then this issue does not exist. Whatever you write to the register get reflected into the output latch value. Hope this clears it up.
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