Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:03 19 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Hardware: PPS (peripherial pin select) configuration in MMbasic?

Author Message
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 02:34am 03 Jul 2020
Copy link to clipboard 
Print this post

Hi All,

I can't determine if MMbasic uses the 'PPS' (peripheral pin select) functionality available in the PIC32MX series of processors.

I came across the problem trying to find out what pins on an Explore 100 chip are used for the various COM (serial Tx/Rx) ports as I want to use three of them. The pin allocation in itself wasn't that easy to find as the 'Micromite User Manual' points to the 'Micromite Plus Manual' for details, but that points back to the 'Micromite User Manual'! The quickest solution was to dig into the source code (it is *so* appreciated that Geoff makes it available).

It does have some conflicting comments in there, but ignoring comments and going to the code, it does spell out what pins are used for what COM ports. However, the pins specified do not line up with the (default) hardware pins the chip uses, and I was wondering if the PPS system is being utilised to remap the pins to the desired peripherals? However, I have not yet (I'm still going) been able to determine if MMbasic is using this functionality (and where), or if it is not.

[my guess is 'yes' as Geoff is *really* into his code and doing things smart, but...]

Cheers,
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 02:51am 03 Jul 2020
Copy link to clipboard 
Print this post

Yes, the PPS functionality is used extensively in the MX170 & MX470 versions.  I don't want to get into supporting the source code but if you look in IOPorts.h you will see a series of defines like below that define the pin mapping:
#define COM1_RX_PPS_OPEN    PPSInput(2, U2RX, RPB11)
#define COM1_TX_PPS_OPEN    PPSOutput(4, RPB10, U2TX);
#define COM1_TX_PPS_CLOSE   PPSOutput(4, RPB10, NULL)
#define COM1_DE_PPS_OPEN    PPSOutput(1, RPB3, U2RTS)
#define COM1_DE_PPS_CLOSE   PPSOutput(1, RPB3, NULL)


Lot of luck trying to modify these.  The PPS system has a lot of restrictions and it is not easy to get what you want.

Geoff
Geoff Graham - http://geoffg.net
 
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 03:35am 03 Jul 2020
Copy link to clipboard 
Print this post

Hi Geoff,

Many thanks for the quick reply!

I have searched for and now found that block (and others like it) in the code, and it has suddenly made everything very clear. Coming from an assembler background I was expecting to see access to the PPS registers directly, but now I see it is being done through the Microchip PPSInput/PPSOutput macros - far more elegant.

My system will have one RS232 port and two RS485 ports, both RS485 with Tx Enable. My goal is to couple these to as much hardware support as possible so I don't have to worry about bit-banging the enable lines. As the manual points out this is already supported on COM1. I'm hoping a Cfunction will let me do the same with a second port.

The more I use MMbasic the more I am impressed by it. I think you've done a fantastic job on it! I just have to get used to doing things with an 'interpreter' mindset rather than a 'compiler' mindset.

Cheers,
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1590
Posted: 06:21am 03 Jul 2020
Copy link to clipboard 
Print this post

MustardMan,

Perhaps I don't understand your problem with the Tx Enable but isn't in just a matter of raising the Tx Enable pin (DE), transmitting the message and then lowering it? Like this:

  Quote  ' Send the Response message
SUB TxMsg
 
PIN(DE) = 1
 TXD$ = TXD$ + CRC16$(TXD$)
 
PRINT #1, TXD$;
 
DO: LOOP UNTIL LOF(#1) = 256: PAUSE 20' Wait til message sent
 PIN(DE) = 0
END SUB

I have used this with the Max485 chip. I did it this way rather than use the inbuilt DE function and have to use an inverter.

There are RS485 interface boards available that generate the DE signal internally. Some other members have used them.

Bill
Keep safe. Live long and prosper.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024