33F Canbus with DMA

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

33F Canbus with DMA

Post by Mikat »

Hi.

Have anyone managed to get internal canbus working with 33F chip, which have can via DMA controller?
I tested with 33F, but I only get some I/O traffic for a moment, about half frame (no valid can message), then the tx pin just pulses.
The hardware should be ok, it works with 30F6012A nicely.
Ben have you tested the code at hardware? The behavior is quite strange, it seems like something is overriding the can tx pin. It doesnt sen even the first message at the end, the timing seems to be wrong, eventhe id doesnt goes right, at any timing at logic analyser.. Does anybody have change to test that can component at 24/33 series chip?
T:Mika

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: 33F Canbus with DMA

Post by kersing »

I'm using CAN on 33FJ series using DMA (there is no other option on these devices). Are you using the Flowcode CAN component?

Can you post your code? (Or attach to PM of sensitive)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: 33F Canbus with DMA

Post by Mikat »

Hi.
Yes, I am using the flowcode internal can component.. I can post the code, but its very simple, just can init and in the loop delay, and can send buffer macro.. It is only to test the can component.
So are you using the 33f internal can, at flowcode6? With success?
T:Mika

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: 33F Canbus with DMA

Post by kersing »

Yes, I'm using dsPIC33FJ internal CAN extensively to communicate between dsPICs.

Please post your code, simple as it might be, the component settings might make a difference.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: 33F Canbus with DMA

Post by Mikat »

Hi.
There is the program, simple can send, and probing the tft backlight drive to see the program is running ok..
bl_1s_tx0.fcfx
Can test
(6.99 KiB) Downloaded 200 times
And here is screenshot for logic program, upper capture is working at 30F6012A and lower is 33FJ256GP506A. As you can see the wavefors are not same shape, so it's not timing issue.. And the tx pin output continues pulsing the way it is at the end of the capture.
33f can.jpg
33f can.jpg (125.46 KiB) Viewed 4446 times
T:Mika

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: 33F Canbus with DMA

Post by QMESAR »

Hello

Looking through your code my guess would be that your Oscillator settings are not running at the intended 50Mhz clock speed you set that effects the baud rate calculation and settings in FC.
what Oscillator(crystal) frequency you have and what is your intended Tcy time you are looking for ? as this directly influence the OSC calculation you perform .
It is aslo good practice to wait for the PLL lock to occurs

An example of the PLL Lock wait

Code: Select all

PLLFBD = 68;              /* M=70 (68 +2)*/
CLKDIVbits.PLLPOST = 0;   /* N1=2 */
CLKDIVbits.PLLPRE = 0;    /* N2=2 */
OSCTUN = 0;         //Tune FRC oscillator, if FRC is used

//Disable Watch Dog Timer
RCONbits.SWDTEN = 0; 
//-------------------------------------------------------------------
// Clock switching to incorporate PLL
__builtin_write_OSCCONH(0x03);   // Initiate Clock Switch to Primary
__builtin_write_OSCCONL(0x01);
while (OSCCONbits.COSC != 0x3);

//--------------------------------------------------------------------
//ensure PLL lock before moving on into application code
//--------------------------------------------------------------------
while(OSCCONbits.LOCK != 1);	/* Wait for Pll to Lock */
Attachments
29.01.jpg
29.01.jpg (51.37 KiB) Viewed 4441 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: 33F Canbus with DMA

Post by kersing »

I've updated the flowchart a bit, could you test it? BTW, the clock setting will probably not be correct as your code defined CLKDIVbits.PLLPOST = 4 which is not a valid value for a 2 bit value (0-3 are allowed), so I assumed you meant divide by 4. (Don't know you hardware so I can't calculate the required value)
Attachments
bl_1s_tx0_mod.fcfx
(7.46 KiB) Downloaded 186 times
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply