dsPIC30F4013 error

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

dsPIC30F4013 error

Post by tanjilul »

Hi, I have been using the dsPIC for a few months now in the setting shown in the screenshot.
untitled1.JPG
untitled1.JPG (33.04 KiB) Viewed 5972 times
untitled.JPG
(96.31 KiB) Downloaded 942 times
But recently it has started to malfuction. Code that had previously worked before, does not anymore.

I have changed computers, changed PICs and also changed the e-block (EB064).

After changing the EB064, my code worked ONLY AFTER SELECTING "HS" as the oscillator. However, after doing so, serial communication has stopped working. Hyperterminal shows random characters when running the test file [Simple 'SendRS232String' command in a while(1) loop].

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC30F4013 error

Post by Benj »

Hello,

What crystal are you using? Is it the 12MHz one supplied with the board?

In your project options you are setting the speed for a 12MHz oscillator so the HS mode of operation should work correctly.

Page 142 of the device datasheet gives a table of all the oscillator modes, EC and ECIO modes are for external clock which is not what you are using on the EB064 board.

I would recommend performing a 1 second LED flasher test on the hardware to confirm your hardware and Flowcode are setup correctly to work together. Once you have this correct your RS232 baud rates should be spot on.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: dsPIC30F4013 error

Post by tanjilul »

Thanks for the reply.

I am using the 12MHz crystal with the board.
I finally got my pic working today, but not the serial communications bit. The oscillator settings is "XT"

I ran a previous version of my code from a few months back, and its works PERFECTLY!!
Under settings, it has "ECIO w/PLL 4x", which is very weird.

I even exported the previous macro into the current file and it still failed.

Please advice.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC30F4013 error

Post by Benj »

Hello,

The XT setting is for clock speeds of 10MHz or less on a 16-bit PIC. The HS setting is for clock speeds higher then 10MHz.

The HS2 W/PLL 4x use the onboard PLL to multiply the input frequency. This one divides the 12MHz input by 2 and then multiplies by 4 to give you 24MHz. You would then put 24000000 into your Flowcode clock speed setting to allow delays etc to be correct on the hardware. I would advise playing around with these setting to get the best speeds from your device.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: dsPIC30F4013 error

Post by tanjilul »

Hi Benj
Thank you for your advice. I have tried the settings that you have suggested (HS2 PLL 4x) and my program works fine. However the serial communication still fails to work.

The program runs fine on the simulation but in hardware for some reason the macro DOES NOT execute entirely. It exits and goes back into main.

I am using a baudrate of 9600 on the pc and in the code.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC30F4013 error

Post by Benj »

Hello,

Have you got the 24000000 as your clock speed in the project options menu? Also have you performed a quick 1 second flasher test to ensure the delays are correct? You may have to enable to clock switching and clock fail safe monitor to allow the PLL setting to work correctly at 24MHz.

Once you have the clock setup correctly in Flowcode so that delays are correct on the hardware it should calculate your baud rates correctly for the UART.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: dsPIC30F4013 error

Post by tanjilul »

Hi,
As 24MHz is not available (20MHz and 40MHz is the nearest). In version 4, I chose 48MHz with HS2 PLL 8x. I just tried 1 second led flasher, it works precisely. But rs232 macro still fails. The macro is an EXACT copy from a working file.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dsPIC30F4013 error

Post by Benj »

Hello,

The input field is a text box which you can type values which are not already in the list. The clock will have to be exact for the baud rate to be calculated correctly.

Can you send in your RS232 program and I will see if I can see anything potentially wrong with it.

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: dsPIC30F4013 error

Post by tanjilul »

Hi Benj,
I have attached the program for you.
The macro in question in "Labview_Connected"
At this moment the program goes upto [LCDPrintstring "L1"] after that it escapes the macro and enter "Check_SD" macro.

Thanks.
Attachments
DAQ Device.fcf_pic16
(65.72 KiB) Downloaded 249 times

tanjilul
Flowcode V4 User
Posts: 11
Joined: Tue Oct 25, 2011 11:25 am
Has thanked: 4 times
Been thanked: 1 time

Re: dsPIC30F4013 error

Post by tanjilul »

Hi Benj

I have finally manged to solve the issue by creating a new macro for serial comms.

Thanks for your help.

Post Reply