mapPps issues

Talk about anything you want!
Post Reply
GrahamM242
Posts: 65
Joined: Fri Feb 21, 2014 6:48 pm

mapPps issues

Post by GrahamM242 » Tue Mar 11, 2014 12:46 pm

I've spent my time scratching my head over why I'm having such issues mapping peripherals to pins. I'm using an MX150 on a breadboard, with caroper's boot loader - I've created the requisite Boards_Defs.h/Board_Dad.c files and modified the boards.txt file to include them.

However, I note that my PPS mapping for output doesn't appear to work correctly. If I try mapping U1TX to device pin 16 (which is valid according to the datasheet) using

Code: Select all

mapPps(12,PPS_OUT_U1TX);
, mapPps returns false! Just for completeness my mapping for output pins looks like the following:

Code: Select all

const uint8_t digital_pin_to_pps_out_PGM[] = {
	_PPS_OUT(_PPS_RPA0R),		//	0  RA0		VREF+/CVREF+/AN0/C3INC/RPA0/CTED1/RA0
	_PPS_OUT(_PPS_RPA1R),		//	1  RA1		VREF-/CVREF-/AN1/RPA1/CTED2/RA1
	_PPS_OUT(_PPS_RPB0R),		//	2  RB0		PGED1/AN2/C1IND/C2INB/C3IND/RPB0/RB0
	_PPS_OUT(_PPS_RPB1R),		//	3  RB1		PGEC1/AN3/C1INC/C2INA/RPB1/CTED12/RB1 
	_PPS_OUT(_PPS_RPB2R),		//	4  RB2		AN4/C1INB/C2IND/RPB2/SDA2/CTED13/RB2 	
	_PPS_OUT(_PPS_RPB3R),		//	5  RB3		AN5/C1INA/C2INC/RTCC/RPB3/SCL2/RB3
	_PPS_OUT(_PPS_RPA2R),		//	6  RA2		OSC1/CLKI/RPA2/RA2
	_PPS_OUT(_PPS_RPA3R),		//	7  RA3		OSC2/CLKO/RPA3/PMA0/RA3
	_PPS_OUT(_PPS_RPB5R),		//	8  RB4		SOSCI/RPB4/RB4
	_PPS_OUT(_PPS_RPA4R),		//	9  RA4		SOSCO/RPA4/T1CK/CN0/RA4
	_PPS_OUT(_PPS_RPB5R),		//	10 RB5		B5PGED3/PRB5/PMD7/RB5
	_PPS_OUT(_PPS_RPB6R),		//	11 RB6		PGB6EC3/RPB6/PMD6/RB6
	_PPS_OUT(_PPS_RPB7R),		//	12 RB7		RPB7/CTED3/PMD5/INT0/RB7
	_PPS_OUT(_PPS_RPB8R),		//	13 RB8		RPB8/SCL1/CTED10/PMD4/RB8
	_PPS_OUT(_PPS_RPB9R),		//	14 RB9		RPB9/SDA1/CTED4/PMD3/RB9
	_PPS_OUT(_PPS_RPB10R),		//	15 RB10		PGED2/RPB10/CTED11/PMD2/RB10
	_PPS_OUT(_PPS_RPB11R),		//	16 RB11		PGEC2/RPB11/PMD1/RB11
	NOT_PPS_PIN,				//	17 RB12		AN12/PMD0/RB12
	NOT_PPS_PIN,				//	18 RB13		AN11/RPB13/CTPLS/PMRD/RB13	
	_PPS_OUT(_PPS_RPB14R),		//	19 RB14		CVREF/AN10/C3INB/RPB14/SCK1/CTED5/PMWR/RB14
	_PPS_OUT(_PPS_RPB15R)		//	20 RB15		AN9/C3INA/RPB15/SCK2/CTED6/PMCS1/RB15
};
and the mapping for input looks like:

Code: Select all

const uint8_t digital_pin_to_pps_in_PGM[] = {
	_PPS_IN(_PPS_RPA0R),		//	0  RA0		VREF+/CVREF+/AN0/C3INC/RPA0/CTED1/RA0
	_PPS_IN(_PPS_RPA1R),		//	1  RA1		VREF-/CVREF-/AN1/RPA1/CTED2/RA1
	_PPS_IN(_PPS_RPB0R),		//	2  RB0		PGED1/AN2/C1IND/C2INB/C3IND/RPB0/RB0
	_PPS_IN(_PPS_RPB1R),		//	3  RB1		PGEC1/AN3/C1INC/C2INA/RPB1/CTED12/RB1 
	_PPS_IN(_PPS_RPB2R),		//	4  RB2		AN4/C1INB/C2IND/RPB2/SDA2/CTED13/RB2 	
	_PPS_IN(_PPS_RPB3R),		//	5  RB3		AN5/C1INA/C2INC/RTCC/RPB3/SCL2/RB3
	_PPS_IN(_PPS_RPA2R),		//	6  RA2		OSC1/CLKI/RPA2/RA2
	_PPS_IN(_PPS_RPA3R),		//	7  RA3		OSC2/CLKO/RPA3/PMA0/RA3
	_PPS_IN(_PPS_RPB5R),		//	8  RB4		SOSCI/RPB4/RB4
	_PPS_IN(_PPS_RPA4R),		//	9  RA4		SOSCO/T1CK/CN0/RA4
	_PPS_IN(_PPS_RPB5R),		//	10 RB5		B5PGED3/PRB5/PMD7/RB5
	_PPS_IN(_PPS_RPB6R),		//	11 RB6		PGB6EC3/RPB6/PMD6/RB6
	_PPS_IN(_PPS_RPB7R),		//	12 RB7		RPB7/CTED3/PMD5/INT0/RB7
	_PPS_IN(_PPS_RPB8R),		//	13 RB8		RPB8/SCL1/CTED10/PMD4/RB8
	_PPS_IN(_PPS_RPB9R),		//	14 RB9		RPB9/SDA1/CTED4/PMD3/RB9
	_PPS_IN(_PPS_RPB10R),		//	15 RB10		PGED2/RPB10/CTED11/PMD2/RB10
	_PPS_IN(_PPS_RPB11R),		//	16 RB11		PGEC2/RPB11/PMD1/RB11
	NOT_PPS_PIN,	//	17 RB12		AN12/PMD0/RB12
	NOT_PPS_PIN,		//	18 RB13		AN11/RPB13/CTPLS/PMRD/RB13	
	_PPS_IN(_PPS_RPB14R),		//	19 RB14		CVREF/AN10/C3INB/RPB14/SCK1/CTED5/PMWR/RB14
	_PPS_IN(_PPS_RPB15R)		//	20 RB15		AN9/C3INA/RPB15/SCK2/CTED6/PMCS1/RB15
};
However, in digging into this, I see the following line in mapPps in wiring.c:

Code: Select all

	/* Check if the requested peripheral input can be mapped to
	** the requested pin.
	*/
	if ((ppsSetFromPin(pin) & ppsSetFromFunc(func)) == 0)
	{
		return false;
	}
Now, for some reason I'm not understanding yet, this fails. ppsSetFromPin would return 0 (

Code: Select all

((3 >> 4) &0x000F)
) and ppsSetFromFunc would return 1 (

Code: Select all

((0x101 >> 8) &0x000F)
), causing the conditional to fail.

What have I missed?

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: mapPps issues

Post by EmbeddedMan » Tue Mar 11, 2014 1:53 pm

I'm pretty sure you're running across a bug that I just fixed in the MPIDE core. The bug was that certain PPS related mapping macros had typecasts of only 8 bit ints, when they needed to return 16 bits.

If you want, you can try the latest MPIDE test build (http://chipkit.s3.amazonaws.com/builds/ ... 7-test.zip for Windows) which has these problems fixed. See if that helps.

*Brian

GrahamM242
Posts: 65
Joined: Fri Feb 21, 2014 6:48 pm

Re: mapPps issues

Post by GrahamM242 » Tue Mar 11, 2014 4:27 pm

I wish it had been that simple! Sadly that didn't fix the issue, but I'll tell you what did - I discovered my own stupidity.

I'd mapped the elements in digital_pin_to_pps_in_PGM[] using the wrong names. I had used the following:
_PPS_IN(_PPS_RPA0R) instead of using
_PPS_IN(_PPS_RPA0)

That, of course, broke the carefully crafted PPS system, and stopped everything working. It's now fixed and seems to work as it should.

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: mapPps issues

Post by EmbeddedMan » Tue Mar 11, 2014 7:44 pm

Very glad to hear it!

*Brian

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: mapPps issues

Post by EmbeddedMan » Tue Apr 22, 2014 1:18 pm

hmm. No posts for many days. Just checking that the forum is still writable.

*Brian

User avatar
majenko
Site Admin
Posts: 2164
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: mapPps issues

Post by majenko » Tue Apr 22, 2014 6:50 pm

EmbeddedMan wrote:hmm. No posts for many days. Just checking that the forum is still writable.

*Brian
No, it isn't. You're just imagining this.

chipKIT is now so perfect nobody has any issues with it.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

JohnL
Posts: 17
Joined: Tue May 20, 2014 9:07 am

Re: mapPps issues

Post by JohnL » Fri Jun 17, 2016 12:16 pm

Graham,
I've created the requisite Boards_Defs.h/Board_Dad.c files and modified the boards.txt file to include them.
If you are still active on the forum.

Would you mind sharing files ?
I am relatively new to MPIDE and would like to get things going with MX150B Uart bootloader.

Would be much appreciated.

Post Reply