Page 1 of 1
dsPIC30F4013 error
Posted: Mon Mar 05, 2012 6:16 pm
by tanjilul
Hi, I have been using the dsPIC for a few months now in the setting shown in the screenshot.

- untitled1.JPG (33.04 KiB) Viewed 5984 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].
Re: dsPIC30F4013 error
Posted: Tue Mar 06, 2012 10:22 am
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.
Re: dsPIC30F4013 error
Posted: Tue Mar 06, 2012 8:15 pm
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.
Re: dsPIC30F4013 error
Posted: Wed Mar 07, 2012 10:27 am
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.
Re: dsPIC30F4013 error
Posted: Thu Mar 08, 2012 9:27 am
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.
Re: dsPIC30F4013 error
Posted: Thu Mar 08, 2012 10:07 am
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.
Re: dsPIC30F4013 error
Posted: Thu Mar 08, 2012 10:58 am
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.
Re: dsPIC30F4013 error
Posted: Thu Mar 08, 2012 3:35 pm
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.
Re: dsPIC30F4013 error
Posted: Thu Mar 08, 2012 4:56 pm
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.
Re: dsPIC30F4013 error
Posted: Wed Apr 04, 2012 7:56 am
by tanjilul
Hi Benj
I have finally manged to solve the issue by creating a new macro for serial comms.
Thanks for your help.