• AVR Freaks

Helpful ReplyHot!Porting from PIC32MX to PIC32MZ

Page: < 123 > Showing page 2 of 3
Author
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/03 02:32:22 (permalink)
0
Thanks, where are these SYS_DEVCON calls from? A harmony library?
 
I don't have any harmony libraries included. 
 
What's the best way of writing a good bit bang method for i2c then? I'd need a start, restart, send data, get data, and stop method I suppose with their own timings?
 
Then I can just build on top of them. 
#21
malaugh
Super Member
  • Total Posts : 396
  • Reward points : 0
  • Joined: 2011/03/31 14:04:42
  • Location: San Diego
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/03 07:17:22 (permalink)
0
They are Harmony files.  I have sent you a private message with the files.  The alternative is to download harmony and extract the files.  The files you need are
 
sys_devcon.h
sys_devcon_cache.h
sys_devcon_cache_pic32mz.S
sys_devcon_pic32mz.c
#22
malaugh
Super Member
  • Total Posts : 396
  • Reward points : 0
  • Joined: 2011/03/31 14:04:42
  • Location: San Diego
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/03 07:21:24 (permalink)
3 (1)
For I2C, yes you need to toggle the SCL and SDA lines with your own timing.   You may want to check the errata, I think only some of the I2C ports are broken.
 
#23
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 03:39:52 (permalink)
0
Getting an odd thing while trying to bit bash the I2C lines
 
When trying to read a byte back from a barometric sensor, I can see the sensor toggling the SDA line to send back the correct data but I'm seeing nothing change on the MZ's input pin??
 
I'm setting the pin back to an input after setting up the data read
TRISGbits.TRISG7 = 1;               // sda input
 
My LATGbits.LATG7 is still = 1 at this point 
 
Then I clock 8-bits and 1-bit NACK but the PORTGbits.RG7 pin doesn't register anything, it just reads 0 throughout even though I see the levels change on a 'scope
 
I must be missing something fairly obvious!
#24
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 04:46:07 (permalink)
4 (1)
The pin is probably in analog mode.
 
#25
Mysil
Super Member
  • Total Posts : 3325
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 04:49:19 (permalink)
3 (1)
Hi,
On MZ devices with PORTG7 bit, this is a pin that may be used for Analog input.
Are you sure that you have enabled the Digital Input buffer,  by setting ANSELG7 bit = 0; ?
 
BTW. to implement I2C signalling correctly, you should check that SDA and SCL signaling actually follow the signal level intended, also when transmitting.
 
On the product webpages for PIC32MM devices, there is code example for I2C bitbanging in a blocking implementation, that means waiting in the driver code when timing each bit transmission. It is fairly correct in checking for clock stretching and bus collison during signaling, but somewhat conservative in timing. 
http://www.microchip.com/...ic32mm0064gpl028 
See: Documentation tab, and Code examples. 
 
In this thread, there is example code, and a variant of the bitbanging driver with timing tightened up,
and some other corrections. http://www.microchip.com/forums/FindPost/989704
The bitbanging engine is in: I2C_Master_MM.S
with configuration settings and function declarations in: I2C_Master_MM.h
There are API functions in: I2C_Master_BB.c
and Header file with API declarations in: I2C_Master.h. 
Application Interface is compatible between  all devices in the thread, and follow function names and argument lists used by MCC.
Application interface is different from what is used by Harmony.
 
Example project for PIC32MM is configured for I2C signaling frequency of 100 kHz.
bitbanging functions have been tested to more than 250 kHz on PIC32MM.
On PIC32MZ,  the bitbanging functions should be useable at 400 kHz, or 1 MHz, if devices and wiring are suitable.
 
While project and examples follow MCC style and concepts, I2C bitbanging driver and I2C functions are general PIC32 code, and should have no other dependencies than XC32 device support file and standard C libraries.
 
Regards,
   Mysil
post edited by Mysil - 2017/05/04 05:57:35
#26
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 05:53:48 (permalink)
4 (1)
Thanks guys, yes had left the pin in analogue mode
I'm now talking to my i2c devices.... :D
 
Now I need to bit bash my external flash chip, get the UART up and running for my bluetooth chip and get the display running properly (have a controller less solution that worked ok on MX but has issues out of the box on the MZ)
#27
malaugh
Super Member
  • Total Posts : 396
  • Reward points : 0
  • Joined: 2011/03/31 14:04:42
  • Location: San Diego
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 08:27:55 (permalink)
4 (1)
I think all the SPI ports work on the MZ Are you using I2C flash? IMHO SPI flash is much easier to use and faster
#28
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/04 08:33:36 (permalink)
0
It's an SPI flash, seems to fire up ok with my bit banged code that worked on the MX, got the UART working ok now, so bluetooth module is happy and communicating with my PC.
 
Had quite a good day in the end!
#29
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 01:28:33 (permalink)
3 (1)
Now I'm working on the LCD again
 
I run a QVGA LCD direct from the micro using the DMA and PMP. My limitation with the MX was that I only had a frame buffer big enough for 8bpp so that slowed my refresh rate down to around 35Hz and meant some colours/lines on the screen didn't look great.
Now with the MZ I can quite easily run it at ~60Hz but I'm not running it correctly yet. It seems like I can only write to the top half of the frame buffer, the last 120 line are always black.
This is how I define my frame Buffer

#ifdef EightBPPVaritronix
#elif defined SixteenBPPVaritronix
#define LINE_LENGTH 320
#define FRAME_HEIGHT 240
#define DUMMY_FRAMES 242 // was 243
#define BLANKING_PERIOD 248 // was 248
#define HORIZ_PORCH 60 // was 70 // new porch length - divides into 320 - was 40
#endif
#ifdef SixteenBPPVaritronix
unsigned short int GraphicsFrame[(BLANKING_PERIOD)][LINE_LENGTH];
#endif

So according to the map file it is 0x26C00 bytes large.
And my DMA handler is thus:
void __attribute__((vector(_DMA1_VECTOR), interrupt(IPL7AUTO), optimize("-fno-shrink-wrap"), nomicromips)) DmaHandler1(void)
{
static short int line = 0;
pbTP60 = 1;
switch(GraphicsState)
{
case LineData: // Line Data
if(line==0)
pbLcdVSYNC=1; // can get rid of VSYNC toggle, just useful for debug - frame rate
#ifdef GraphicsLookUp
if(line<(FRAME_HEIGHT))
//lineBuffer[j++] = COLOR_TABLE[(GraphicsFrame[(FRAME_HEIGHT-1)-line][i])];
DCH1SSA=_VirtToPhys((const void*)&GraphicsFrame[(FRAME_HEIGHT-1)-line][0]);
#endif
if(line<DUMMY_FRAMES)
pbLcdDataEnable = 0; // data enabled High - only when valid data - set low
DCH1SSIZ = (unsigned short int)LINE_LENGTH*2; // was *2
GraphicsState=HorizFrontPorch;
if(line==10) // reset after ten frames so big enough signal to see on scope - debug only
pbLcdVSYNC=0;
break;
case HorizFrontPorch: // Horizontal front porch timing 31~80 dotclks according to datasheet
if(++line>BLANKING_PERIOD)
line=0;
pbLcdDataEnable = 1;
DCH1SSIZ = (unsigned short int)HORIZ_PORCH*2;//*2; // Front porch (20) double as 16-bit
GraphicsState = LineData;
break;
default:
break;
}
// exit interrupt handler
DCH1CONbits.CHEN=1;
DCH1INTbits.CHBCIF=0;
IFS4bits.DMA1IF=0;
pbTP60 = 0;
}

When trying to just test some basic colours I can only seemingly write to the first 120 lines??
I've tried the following:
void ToggleBackGroundColour(void)
{
static unsigned char colour = 0;
#ifdef DMASuspend
DMACONbits.SUSPEND = 1; // Suspend ALL DMA transfers
#endif
memset( &GraphicsFrame, (unsigned short int)COLOR_TABLE[colour++], sizeof(GraphicsFrame)/2 );
memset( &GraphicsFrame[124][0], (unsigned short int)COLOR_TABLE[colour++], sizeof(GraphicsFrame)/2 );
#ifdef DMASuspend
DMACONbits.SUSPEND = 0; // restart DMA transfers
#endif
if(colour > 20)
colour = 0;
}

Have I not defined my Frame buffer correctly? Do I need to do anything special in regards to what area of memory it goes into as it is so large? I had no problems with my 320x240x1 byte frame buffer when it was 8bpp
#30
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 01:35:56 (permalink)
0
Is the forum having trouble again? I keep getting permission denied when starting a new topic or trying to reply to topics
#31
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 01:45:36 (permalink)
0

Access Denied

You don't have permission to access "http://www.microchip.com/forums/post.aspx?" on this server.
Reference #18.c9d3dead.1494405902.29537de3
#32
CinziaG
mind power
  • Total Posts : 3144
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 02:18:16 (permalink)
0
alex_elec
Is the forum having trouble again? I keep getting permission denied when starting a new topic or trying to reply to topics




it's not "again", it's "as always" grin
You may have links or emoticons in your text, or other reserved words...

in 2018 you signed for your annihilation. in 2019 it will come ;) I promise
#33
simong123
Lab Member No. 003
  • Total Posts : 1290
  • Reward points : 0
  • Joined: 2012/02/07 18:21:03
  • Location: Future Gadget Lab (UK Branch)
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 03:56:43 (permalink)
3 (1)
GraphicsFrame requires the coherent attribute.
unsigned short int __attribute__((coherent)) GraphicsFrame[(BLANKING_PERIOD)][LINE_LENGTH];

Also, I don't think your memset commands work the way you think they do. (hint:- casting to unsigned short does nothing - memset can only set bytes)
#34
Bill Yonkers
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2012/09/12 19:06:30
  • Location: 0
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/10 20:14:35 (permalink)
0
Hello,
 
Moving from Mx to Mz for a QVGA to 16 bit also. 
 
In Mx used modified linker script to set up frame buffer,
 
I use __attribute__ ( ( persistent ))  for my frame buffer.  It is the same as coherent, removing it from the cached area, but also removes buffer from initialization.
 
In your DMA initialization Did you change the
DCH1CSIZ=  from 1 to 2; 
 
#35
alex_elec
Junior Member
  • Total Posts : 94
  • Reward points : 0
  • Joined: 2014/03/26 04:41:13
  • Location: UK
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2017/05/12 01:49:15 (permalink)
3 (1)
Thanks Simon, yes I was actually also screwing up an extern for the Graphics frame as I had a few ifdefs round it depending on screen type etc, one of which was completely wrong.
 
I was also definitely using memset the wrong way in that instance!
#36
MarPICnus
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2018/08/16 11:13:00
  • Location: 0
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2018/11/07 06:48:19 (permalink)
0
Hello Alex_elec
 
I'm also starting to port to the PIC32MZ. I've used the Legacy library for a TCPIP stack and added MODBUS TCP onto it.
It is working on the PIC32MX. Now I have to port to the PIC32MZ
What I have done so far is:
 
  1. Created a new configuration name, "XC32-PIC32MZ_SK_ETH204"
  2. Selected my PIC32MZ2048EF144 processor as a device
  3. Copied all previous Preprocessor Macros over to my new config name
I  use XC32 2.10 (It does support my PIC32MZ2048EF144
When I compile I get a lot of errors as shown below:
 
It seems all the errors are related to peripheral libraries, as all errors are related to library files in the peripheral folder.
So I read your post on the forum that you had to remove the PLIB dependancies. How do I do this?
 
Help will be appreciated.
Marinus
 
Example of some errors:
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:81:10: error: token ""EF"" is not valid in preprocessor expressions
#elif (((__PIC32_FEATURE_SET__ >= 100) && (__PIC32_FEATURE_SET__ <= 299)) || defined(__32MXGENERIC__))
^
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:83:10: error: token ""EF"" is not valid in preprocessor expressions
#elif ((__PIC32_FEATURE_SET__ >= 300) && (__PIC32_FEATURE_SET__ <= 499))
^
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:85:10: error: token ""EF"" is not valid in preprocessor expressions
#elif (((__PIC32_FEATURE_SET__ >= 500) && (__PIC32_FEATURE_SET__ <= 799)) || defined (__32MXPOCONO__))
^
In file included from c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\adc10.h:45:0,
from c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\plib.h:49,
from ../../../Microchip/Include/Compiler.h:117,
from ../Configs/TCPIP ETH795.h:53,
from ../TCPIPConfig.h:130,
from ../BerkeleyTCPServerDemo.c:55:
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:88:4: error: #error "Device not supported by the interrupt peripheral library"
#error "Device not supported by the interrupt peripheral library"
^
In file included from c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\adc10.h:45:0,
from c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\plib.h:49,
from ../../../Microchip/Include/Compiler.h:117,
from ../Configs/TCPIP ETH795.h:53,
from ../TCPIPConfig.h:130,
from ../BerkeleyTCPServerDemo.c:55:
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:119:58: error: '_INTCON_SS0_MASK' undeclared here (not in a function)
INT_REGISTOR_SET_SELECT_SS0 /*DOM-IGNORE-BEGIN*/ = (_INTCON_SS0_MASK) /*DOM-IGNORE-END*/
 
#37
NKurzman
A Guy on the Net
  • Total Posts : 17389
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: Porting from PIC32MX to PIC32MZ 2018/11/07 07:09:21 (permalink)
0
PLIB does not support the PIC32MZ. The expect you to use harmony. Harmony does have PLIB like libraries, but you will need to make a lot of changes to use it.
#38
malaugh
Super Member
  • Total Posts : 396
  • Reward points : 0
  • Joined: 2011/03/31 14:04:42
  • Location: San Diego
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2018/11/07 12:16:50 (permalink)
0
the 
 
c:\program files (x86)\microchip\xc32\v2.10\pic32mx\include\lega-c\peripheral\int.h:81:10: error: token ""EF"" is not valid in preprocessor expressions
#elif (((__PIC32_FEATURE_SET__ >= 100) && (__PIC32_FEATURE_SET__ <= 299)) || defined(__32MXGENERIC__))
 
You are getting is due to the __PIC32_FEATURE_SET__ macro being defined by Microchip for an MZ as an alphanumeric string.  Regardless of the PLIB situation, you will need to fix this.   I have not tried to but something like
 
#undef  __PIC32_FEATURE_SET__
#define  __PIC32_FEATURE_SET__ 100
 
Should get rid of the errors
 
 
#39
MarPICnus
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2018/08/16 11:13:00
  • Location: 0
  • Status: offline
Re: Porting from PIC32MX to PIC32MZ 2018/11/12 01:42:36 (permalink)
0
I'm also busy Porting form PIC32MX to PIC32MZ. 
I had a MODBUS TCP project running on PIC32MX using PLIBS.
 
I see in this forum you are talking about removing PLIB dependancies. 
I have not started doing this yet, but can I use the Harmony libs and put them in the place of the PLIBS?
 
I don't really have a clear idea where to start.
 
Thanx for helping.
#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5