• AVR Freaks

Helpful Replywhat would you do with a dual core dspic?

Page: << < ..1112131415.. > >> Showing page 15 of 19
Author
Antipodean
Super Member
  • Total Posts : 1778
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 09:25:30 (permalink)
4 (1)
Jack_M
OT: did we break the forum? I see 15 pages of this topic, but your post was at page 14. My reply was also added at page 15 if i try to go to page 15 the page keeps crashing and reloading



People break the forum because they don't read the footer on my messages and don't adjust my alias when they reply to a message I post. The reason is my alias contains the name of a certain product from a company named after a fruit, and the forum blocks messages that mention such products.
 
However the forum software keeps a track of these messages and they lead the visible thread creating a page that the software thinks should be there, but it isn't, but it is, but it isn't ... and so the new page blinks until a proper message appears on it.
 
Only Microchip could have software that does this ...
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
Antipodean
Super Member
  • Total Posts : 1778
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 09:27:16 (permalink)
5 (1)
Jack_M
meanwhile, this app note popped up
 
http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en606706
 
or at least it wasn't there the other day when i visited the product page again





This has been available for a little while, just the link on the product page didn't work, but if one went googling for it then it was easily found.
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
Antipodean
Super Member
  • Total Posts : 1778
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 09:28:33 (permalink)
3 (1)
du00000001
Page 15 now ?





My two posts pushed it over ... 
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
du00000001
Just Some Member
  • Total Posts : 3243
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 10:10:10 (permalink)
3 (1)
@ naedopitnA
So the message will not "disappear" - it's more as if these replies were somewhat "invisible"  grin

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
Howard Long
Super Member
  • Total Posts : 727
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 16:03:48 (permalink)
5 (2)
marcov
Btw, the code I quoted comes from the CH examples on the dspic33ch128mp508 PIM page:
 
https://www.microchip.com...roductDetails/MA330040
 
This is currently the only source of CH code that I have. If people have more sources, please post.




Here's a stereo blinky, on Master on RB5 and Slave on RB6, with minimal nonsense. No crystals, no PLL, just the FRC.
 
Environment: MPLAB X 4.20, XC16 1.35, Windows 10 x64.
 
CPU is dsPIC33CH128MP502 SSOP on a breakout board, on a solderless breadboard. Just powered from 3.3v lab supply with decoupling caps and ICD3 programmer/debugger on PGD1/PGC1.
 
Two projects, named "d33ch128mp502_001m" (master) and "d33ch128mp502_001s" (slave).
 
Make the slave project a slave of the master project.
 
Make sure you've also checked the Build box in the master project's Properties->Categories -> Conf -> Slaves -> Slave Projects.
 
I found out these two things the hard way:
 
o NO SPACES IN FILE NAMES
o TARGET SLAVE PROJECT NAME MUST BE A VALID C IDENTIFIER
 
Here's the "main.c" for the master project, note how the slave's project name is used to reference an auto-generated .h file, and also as an C identifier on the master for the slave's binary image.

// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Source Selection (Internal Fast RC (FRC))
#pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source)
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function bit (OSC2 is clock output)
#pragma config FCKSM = CSECMD // Clock Switching Mode bits (Clock switching is enabled,Fail-safe Clock Monitor is disabled)
// FWDT
#pragma config FWDTEN = ON_SW // Watchdog Timer Enable bit (WDT controlled via SW, use WDTCON.ON bit)
// FICD
#pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
#pragma config CPRB5 = MSTR // Pin RB5 Ownership Bits (Master core owns pin.)
#pragma config CPRB6 = SLV1 // Pin RB6 Ownership Bits (Slave 1 core owns pin.)
// FS1OSCSEL
#pragma config S1FNOSC = FRC // Oscillator Source Selection (Internal Fast RC (FRC))
#pragma config S1IESO = OFF // Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source)
// FS1OSC
#pragma config S1OSCIOFNC = OFF // Slave OSC2 Pin Function bit (OSC2 is clock output)
#pragma config S1FCKSM = CSECMD // Clock Switching Mode bits (Clock switching is enabled,Fail-safe Clock Monitor is disabled)
// FS1WDT
#pragma config S1FWDTEN = ON_SW // Watchdog Timer Enable bit (WDT controlled via WDTCON.ON bit)
// FS1ICD
#pragma config S1ICS = PGD2 // ICD Communication Channel Select bits (Communicate on PGEC2 and PGED2)
#pragma config S1ISOLAT = ON // Isolate the Slave core subsystem from the master subsystem during Debug (The slave can operate (in debug mode) even if the SLVEN bit in the MSI is zero.)
#include <xc.h>
/* 16-bit peripheral library for access to delay_ms() function. */
#define FCY 8000000
#include <libpic30.h>
/* Access to slave core image. */
#include "d33ch128mp502_001s.h"
int main ( void )

/* Program and start the slave core image. */
_program_slave(1,0,d33ch128mp502_001s); 
_start_slave();

TRISBbits.TRISB5=0;

while(1)

LATBbits.LATB5=1;
__delay_ms(300);
LATBbits.LATB5=0;
__delay_ms(300);
}
}
 

 
Here's the "main.c" for the slave project:

#include <xc.h>
/* 16-bit peripheral library for access to delay_ms() function. */
#define FCY 8000000
#include <libpic30.h>
int main(void) 

TRISBbits.TRISB6=0;

while(1)

LATBbits.LATB6=1;
__delay_ms(350);
LATBbits.LATB6=0;
__delay_ms(350);
}
}

qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/18 17:00:12 (permalink)
4 (1)
du00000001
@ naedopitnA
So the message will not "disappear" - it's more as if these replies were somewhat "invisible"  grin

It's the forum software fighting with the firewall software.
The forum updates the post count, then the firewall blocks it actually adding the post text to the database, breaking the intended flow of the forum software in a way it doesn't expect.
The people running the web server are separate to the people running the forum, and have zero interest in changing the firewall.
This is compounded by the fact that the firewall only applies to non-Microchip employees, so anyone accessing this forum from Microchip HQ does not see the problem...
 
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 03:05:24 (permalink)
0
Basically my code is identical to Howard's Smile
Only used entire PORTA for Master and entire PORTB for Slave.

GENOVA :D :D ! GODO
Howard Long
Super Member
  • Total Posts : 727
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 06:08:40 (permalink)
0
DarioG
Basically my code is identical to Howard's Smile
Only used entire PORTA for Master and entire PORTB for Slave.




I found that the example code was a good start, better than reading an 800+ page data sheet and the application note.
 
I don't yet have the PIM, it's on order, so I first hacked the example code to work on my 28 pin dual core dsPIC, and gradually removed all the cruft until I was left with two .c files. That took about half an hour.
 
Flushed with success, I thought, I know, I'll see if I can do this from scratch. 1.5 hours later I got it to work, which is why I left the caveats about file names and valid C identifiers, and how to build the combined slave and master.
 
The good news is that once you've figured it out it seems really quite painless. The problem is that it's not entirely obvious how it works, i.e., linking the slave's code into your own. There's a bin2hex in the build steps of the master project that somehow magically builds a .h as well as .o file from the slave's .elf. The .h is referred to in your master .c source file and it includes a reference to the slave's blob object code. This bin2hex step fails if you don't use C style identifier name for your slave's project name. If seems a bit hacky to me, but it works well in practice, and as long as you accept its fiddling behind the scenes, it's actually quite developer friendly.
 
The two lines
 

_program_slave(1,0,d33ch128mp502_001s); 
_start_slave();
[/code]
 
are part of the dsPIC33CH's distributed C library and defined somewhere inside the XC hierarchy. I assume you muse have a pretty recent MPLAB X and XC16 for all of this to work.
 
To assign pins to the secondary core, you need to use the config bits. All config bits are only defined inside the master. I don't know yet if you can change the pin assignment mux at run time.
 

#pragma config CPRB5 = MSTR // Pin RB5 Ownership Bits (Master core owns pin.)
#pragma config CPRB6 = SLV1 // Pin RB6 Ownership Bits (Slave 1 core owns pin.)
[/code]
 
For the master, you choose the dsPIC33CHnnnMPnnn processor when setting up the master project. For the slave, you choose the dsPIC33CHnnnMPnnnS1 processor. You link the slave project to the master using some new MPLAB X functionality. I found that to auto build everything form the master project, you need to turn on a check box as I described.
Howard Long
Super Member
  • Total Posts : 727
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 06:10:24 (permalink)
4 (1)
Resubmitting due to formatting problem, cannot seem to edit, acces is denied.
 
DarioG
Basically my code is identical to Howard's Smile
Only used entire PORTA for Master and entire PORTB for Slave.




I found that the example code was a good start, better than reading an 800+ page data sheet and the application note.
 
I don't yet have the PIM, it's on order, so I first hacked the example code to work on my 28 pin dual core dsPIC, and gradually removed all the cruft until I was left with two .c files. That took about half an hour.
 
Flushed with success, I thought, I know, I'll see if I can do this from scratch. 1.5 hours later I got it to work, which is why I left the caveats about file names and valid C identifiers, and how to build the combined slave and master.
 
The good news is that once you've figured it out it seems really quite painless. The problem is that it's not entirely obvious how it works, i.e., linking the slave's code into your own. There's a bin2hex in the build steps of the master project that somehow magically builds a .h as well as .o file from the slave's .elf. The .h is referred to in your master .c source file and it includes a reference to the slave's blob object code. This bin2hex step fails if you don't use C style identifier name for your slave's project name. If seems a bit hacky to me, but it works well in practice, and as long as you accept its fiddling behind the scenes, it's actually quite developer friendly.
 
The two lines
 
 

_program_slave(1,0,d33ch128mp502_001s); 
_start_slave();

[/code]
 
are part of the dsPIC33CH's distributed C library and defined somewhere inside the XC hierarchy. I assume you muse have a pretty recent MPLAB X and XC16 for all of this to work.
 
To assign pins to the secondary core, you need to use the config bits. All config bits are only defined inside the master. I don't know yet if you can change the pin assignment mux at run time.
 
 

#pragma config CPRB5 = MSTR // Pin RB5 Ownership Bits (Master core owns pin.)
#pragma config CPRB6 = SLV1 // Pin RB6 Ownership Bits (Slave 1 core owns pin.)

[/code]
 
For the master, you choose the dsPIC33CHnnnMPnnn processor when setting up the master project. For the slave, you choose the dsPIC33CHnnnMPnnnS1 processor. You link the slave project to the master using some new MPLAB X functionality. I found that to auto build everything form the master project, you need to turn on a check box as I described.
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 06:22:48 (permalink)
0
Yeah, agreed on it all. I did not try the demo code: I was just following this thread, let the MPLAB CONFIG utility generate them (and hence my doubt above), and inserted the simple code for toggling with delay.
Then I faced some more doubts about Clock and PLL (see above again).
And the Slave programming... yeah, I wrote above my further questioning Smile but all ok.
 
Next part would be using the interchange schratchpad..

GENOVA :D :D ! GODO
Howard Long
Super Member
  • Total Posts : 727
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 12:29:55 (permalink)
3 (1)
Yes. I wanted to make the simplest possible example, otherwise you’re second guessing what all the other nonsense is for. In the light of my findings, using the PIM’s example code as a starting point and parrring it down undoubtedly saved a lot of time in that respect.

I’d imagine trying to achieve this simple example from scratch is largely a lesson in pinning the tail on the donkey!
Howard Long
Super Member
  • Total Posts : 727
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 13:35:33 (permalink)
0
I should add that I don’t have a use for these devices yet, but I do find this sort of stuff interesting. I’m not sure what I’d use it for that a PIC32MZ EF couldn’t achieve for example.
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 15:55:25 (permalink)
0
Agreed, "a solution looking for a problem" as somebody said!
 
Will see...
In any case, I prefer the PIC24/dsPIC architecture to the PIC32 one... for some reasons.

GENOVA :D :D ! GODO
NorvisLM
Super Member
  • Total Posts : 80
  • Reward points : 0
  • Joined: 2015/10/06 07:32:11
  • Location: 0
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/19 17:31:25 (permalink)
4.5 (2)
DarioG
Agreed, "a solution looking for a problem" as somebody said!
 
Will see...
In any case, I prefer the PIC24/dsPIC architecture to the PIC32 one... for some reasons.


I was glad to see MC's continued commitment to the 16 bit architecture, however I'm waiting for the Quad Cores to be released so I can blink 4 LEDs. 
 
JPortici
Super Member
  • Total Posts : 851
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 01:07:49 (permalink)
4 (1)
DarioG
Agreed, "a solution looking for a problem" as somebody said!
 
Will see...
In any case, I prefer the PIC24/dsPIC architecture to the PIC32 one... for some reasons.




to me it's mainly this, sometimes i actually use the dsp core for integer or fixed point math, the hardware circular buffers.
Then the device is a tad simpler, yet very powerful.
I really like the instruction set better
 
solution looking for a problem? maybe. i hoped i had more flexibility on the peripheral assignment (i would have needed the lower latency of the slave core for the CCPs, which are on the master core.) but in reality the MIPS bump alone makes them higher performance.
 
Also hoped it had moar pins and usb, i have used all 144 pins of the MU814 for a prototype that i want to port to the CH. Features will inevitably be reduced (no usb on board, half the IC/OC) so maybe 80pin will be enought.
 
Actually, if just they did the dual core version of the MU814 i would truly be satisfied :) i have a problem that needs this solution: Offloading 2xCAN and communication and supervisory to one core while the other is very busy with the digital peripheral and a bunch of analog.
 
Incidentally, from first testing the PIC32MK wasn't going to make it while the dsPIC was just right there and would have benefitted for a MIPS bump
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 01:32:52 (permalink)
0
Ok Smile
Yesterday actually I had talk about an old project, dealing with a TFT display and handling a quite "serious" amount of incoming data via USART and... we had to fine-tune (with pain) the timings of USART, PMP and more. With two cores we'd had our life easier.

GENOVA :D :D ! GODO
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 01:33:02 (permalink)
0
bump

GENOVA :D :D ! GODO
NorvisLM
Super Member
  • Total Posts : 80
  • Reward points : 0
  • Joined: 2015/10/06 07:32:11
  • Location: 0
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 13:31:46 (permalink)
0
NOP
NOP
NOP
NOP
du00000001
Just Some Member
  • Total Posts : 3243
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 13:34:27 (permalink)
3 (1)
xxx MNOPs ?

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
NorvisLM
Super Member
  • Total Posts : 80
  • Reward points : 0
  • Joined: 2015/10/06 07:32:11
  • Location: 0
  • Status: offline
Re: what would you do with a dual core dspic? 2018/07/20 13:36:01 (permalink)
3 (1)
Wanted to see if it was effective as a Forum Blink Avoidance Measure.
Page: << < ..1112131415.. > >> Showing page 15 of 19
Jump to:
© 2019 APG vNext Commercial Version 4.5