News:

Let's find out together what makes a PIC Tick!

Main Menu

help:using (PPS) for new 8-Bit Devices

Started by okmn, Apr 24, 2021, 11:56 AM

Previous topic - Next topic

okmn

I want to make sure that "pps" is used.

for example PIC18F47Q10 has 2 ccp(to use as pwm out )
and has 2 standart pwm out.

i will configure CCP1 as pwm (with timer 2) and will connect it to RC7 and RC5 pins together
but can I choose the pwm signal in the code to which pin to transfer it to?

if i want can take a pwm signal to that 2 pins in same time or i will write  2 "if statement" ;
and RC7 will active in statetment1, RC5 will off
RC5 will active in statetment2 RC7 will off

pwm signal will not at RC5 pin while RC7 active or vice versa.
I wonder if I got it right

if i understood correctly with which commands/statements/expression can i do this algorithm in positron?
setpin ,clear pin , output, high , low, get pin ,set, clear,

I think I'm lost again in a vicious circle!

PPSUSING.jpg

See_Mos

I can see that what you want is possible by changing the PPS registers but I never used a device with PPS.  It looks quite complicated.  This explains more about PPS than than the device data sheet.

http://ww1.microchip.com/downloads/en/DeviceDoc/70190E.pdf

OG

If I don't know wrong, a peripheral unit (eg pwm1) can be connected to one pin at the same time.
After PPS assignments, it must be locked with PPSLOCKED bit.

okmn

#3
so, me too i knew it is not possible but it looks possbile with new series PIC mcus like model q serisi even k42 series(q series is new for me even pic18 is new for me)

look at the the picture i configured with mcc software and ti is look possible(mcc there are noany warnings) but i can not be sure .
to be sure i am studing datasheet and some help documnets;
if i can learn as sure i will public here
but may be soe one or some ones know this issue good!

How can I use(making pin enable) these 2 outputs at separate times and under separate conditions?

Microchip says about pps for 8 bit devices;
"For 8-bit PPS, peripheral input and output signals need to be selected before the peripheral is enabled. Then the peripheral should be enabled after both input and output selections have been completed.

PPS has its limitations though. Only digital signals are included in the selections. All analog inputs and outputs remain fixed to their assigned pins due to the internal circuitry requirements."


"Each Peripheral output can be connected to a selected I/O pin through the PPS. This is done in a similar fashion to the input selection except that selecting the output connection is opposite from the input selection. Instead of the register being named a peripheral nickname followed by PPS, the output is the pin name followed by PPS. Thus, the pin RB0 would have a RB0PPS register to select its connection.

There are five bits in the Output Source register used to choose the connection. These five bits select the Peripheral output that the pin will be connected to. (The example here is for the PIC16F1708.)"


Example
Here is the code in MPLAB® XC8 format for setting the USART TX output pin to RA0:

RA0PPSbits.RA0PPS = 0x14;    // EUSART1:TX1->RA0
In MPASM Assembly format CLC1OUT Pin is connected to RA5

Banksel RA5PPS     ; go to bank with RA5PPS registers
movlw 0x04          ; load value for CLC1OUT
movwf RA5PPS      ; to RA5PPS register

ppsoutputchoice.png



pps_pwmjpg.jpg

okmn

#4
Quote from: OG on Apr 25, 2021, 07:08 PMIf I don't know wrong, a peripheral unit (eg pwm1) can be connected to one pin at the same time.
After PPS assignments, it must be locked with PPSLOCKED bit.


i think pps "lock and unlock" deppent the user selecting ,an optional usage has been introduced (I think)
look the PPS1WAY OPTİONS

PPS1WAY2.jpg

pps1way.jpg

tumbleweed

Quotei think pps "lock and unlock" deppent the user selecting ,an optional usage has been introduced (I think)
Yes, the use of PPS LOCK/UNLOCK is completely optional. It's not required, and PPS is unlocked by default.

You can map an output function to multiple pins simultaneously. That is, you can have the CCP1 output appear on two pins (or more).
If you want to disable a pin then map it back to the port pin LAT (RxyPPS = 0).

You can only map an input function to a single pin.

okmn

yeah ,
 just the LAT using is ok !. to make my idea
so i have to create a procedure in proton ?
or there is/are special command to  make "the pin" enable/disable?

OG

#7
https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F27-47Q10-Data-Sheet-40002043E.pdf
page 288

The notation "Rxy" is a place holder for the pin identifier.
The 'x' holds the place of the PORT letter and the 'y' holds the place of the bit number.
For example,
Rxy = RA0 for the RA0PPS register.


page 289




Value required 0x00 for LAT assignment (LATxy)

for PORTC.5
RC5PPS = %00000000  (or 0, or $00 )


Required value 0x05 for CCP1 assignment 

for PORTC.5
RC5PPS = %00000101 (or 5, or $05 )

I hope I wrote it correctly.

towlerg

I probably get in trouble for mentioning this but there is a standalone PPS config program (18 and 16) packaged with Great Cow Basic. It uses MicroChip config data.

top204

#9
John has also placed a tool within his, excellent, PositronStudio IDE for PPS selection.

It's good to have a seperate program that manages things for a user, but it can also make the user a bit lazy so they do not have to learn how things actually work. ;-) The fun of electronics and programming is the learning process, even when it is a commercial product that is being designed and written, because what is learned gets carried on to other projects, and the fact that a user knows how it works allows them to know that "it" will work for a solution in new firmware.

towlerg

Hi Top204

"but it can also make the user a bit lazy so they do not have to learn how things actually work. ;-)"

Kind of an odd remark from a compiler author :-J

top204

#11
Not really!

A compiler is another language, just as assembler is. It is not a simple remedy for understanding the device it is being used on. With any microcontroller, it is very important to understand the device, and a langauge gives that facility, but there is still a learning process with a language, unlike the "press this button and I'll do it all for you" mechanisms that pop up all over the place! Where is the learning in them? So if they do not work 100%, and the program that uses what they produce does not work 100%, how can a person know what is wrong, because they did not learn how it works anyway? The same with all the libraries that are used, especially in C++. Quite a lot of them do not work 100%, so when the program that is using them goes wrong, the user has no way of knowing what is wrong!

Also, how can a user know what is required if they do not undstand how something works?

towlerg

Sorry Top, failed attempt at humor.

towlerg

Can't edit previous.

PPS can be a PITA, by all means try to work it out manually (good luck understanding mc data sheet on this issue) bu check with whatever tool you can find.

top204

I could see the humour in it, but I had to respond for some people reading the thread that didn't. :-)

I agree, the PPS method on PIC microcontrollers is a mess! They have also changed the way it works three times up to now! It is very powerful and I wish I could make a simple directive in the compiler for it, but, as always, microchip keep changing their mind how it works on devices, so I would be going around in circles trying to find out "what this device requires" for all peripherals.

I had a to do a similar thing when implementing PPS for the peripherals that the compiler's commands support, because the compiler automatically sets the PPS for USARTs and CCP peripherals based upon the Declare used for the pins, and that itself was a bloody nightmare because of all the "major" changes in how it is implemented, and name changes that microchip have made with different devices. If you open the PPI files, some now have a XXX_Type= directive so the compiler can use a different method of controlling a peripheral. I just wish they would make their mind up at some time in the future!