UART on DsPic33FJ256MC710

Post Reply
Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

UART on DsPic33FJ256MC710

Post by Ender » Sat Oct 11, 2008 1:35 am

Hello,

The Simulink design in attachment works with a DsPic33FJ256GP710 but doesn't work with a DsPic33FJ256MC710.
I tried at 9600 baud and 115200 baud.

Could you peek an eye please?
Attachments
Source_one_sinus_to_RS_9600_on_MC.mdl
(25.96 KiB) Downloaded 1687 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: UART on DsPic33FJ256MC710

Post by LubinKerhuel » Sat Oct 11, 2008 6:03 pm

Hi Ender,

I did not see obvious error.
The model However, the model send only 100 bytes / seconds with your configuration (time step of the sinus block is 100Hz, time step for the model is 1KHz.

Do you have an electrical signal on the Tx pin of UART 2 ?
if yes, you should check your quartz configuration.

Otherwise, let me know.
I successfully tested the DsPic33FJ256MC710 at least on UART 1.

Lubin

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Mon Oct 13, 2008 8:12 pm

Hi Lumbin, thank for this quick answer and sorry I didn't work this WE.

I know for the 100Hz and 1KHz, I tried with many speed and I sent you a version with the simulation/solver/fixed_step time constraint at 1Khz and a block with 100hz. But is there a link between the simulation time step and the Dspic compiler work ?

1__Regardless, the code doesn't work with a block at 1Khz too.

2__I use a Explorer 16 Board with a 40Mhz Oscillator, but I didn't change the capacitors close to the Oscillator (am I need to do?). If I use a C code in Mplab to send a ramp of values with your frame, the GUI display the signal. So I think the hardware configuration is fine.

3__I ever saw the same problem on a Dspic33FJ256GP on July, when I installed the licensed version of your blockset, I have changed the C compiler version for the 3.11 too. From that time I work with the 3.10b version. But the next week, I installed a new licensed version of MPLAB Dspic C compiler so Maybe there are compliance problems. I’am using:
Mathlab 2007b, Dspic Blockset2007B licenced and MPLAB_C_dsPICFullv3_10b Licenced: with these the model work at 1khz, 115200baud on a Dspic33FJ256GP710 but doesn’t on Dspic33FJ256MC710.
I’ll change of version and will see.

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Mon Oct 13, 2008 8:52 pm

With Mathlab 2007b, Dspic Blockset2007B licensed and MPLAB_C_3.11 student, the model 1khz_115200 baud:
1___ doesn't work on Dspic33FJ256MC710.
2___ And it doesn’t work with a Dspic33FJ256GP710 too of course I changed the target in Master and I compiled the code every time.
3___The Rs232gui receipt few octets but the graph doesn't display. On the pin 2 of RS232 the signal exists and seems good. With my own Labview RS232 interface, Labview shows a framing error.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: UART on DsPic33FJ256MC710

Post by LubinKerhuel » Mon Oct 13, 2008 10:50 pm

Hi Ender,

I tested the dsPIC_33f_Explorer16.mdl demo (in the demo directory of the blockset) with the explorer16 board equipped with the 33f256GP710 and the original 8Mhz quartz.
It works successfully (Matlab 2008a, gcc version 4.0.3 (dsPIC30, Microchip v3_11) Build date: Jul 16 2008 student version because my license is out of date)

Could you check that the dsPIC is working at a proper frequency (have an I/O blinking and check its frequency, or use a LED at 1Hz for example)
If there is a bug, It may be at the configuration of the UART (but as I tested, I do not think so), or it may be a problem dealing with the clock/timer of the dsPIC.

Lubin

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Mon Oct 13, 2008 11:12 pm

I checked your idea the led blink at 1.5s = 0.66Hz instead of 1s.

The width of the start bit on the COM is 25µS and the frame is just litle bit more than 700µs at 115200baud
The widths between to dot are 2.74 ms instead of 1ms.

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Mon Oct 13, 2008 11:36 pm

Could you build and send to me an .Hex file for 115200baud and an 40Mhz oscillator, please ?

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: UART on DsPic33FJ256MC710

Post by LubinKerhuel » Mon Oct 13, 2008 11:45 pm

If led blink at 1.5s, widths between dots should be 1.5m instead of 2.74ms ?

Either there is a bug in the code generated by the blockset.
Neither the quartz is not at 40Mhz but oscillate at 26.6Mhz. You could try to declare the quartz as a 26.6Mhz quartz in the Master block...

Attached are the two requested .hex file
Attachments
dsPIC33f_Explorer16_MC_GP710.zip
(8.54 KiB) Downloaded 1676 times

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Mon Oct 13, 2008 11:56 pm

I tried with my C code on MPLAB for 115200baud the start width is 8.5µs and the Gui receipt the dots.

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Tue Oct 14, 2008 12:03 am

I declared the quartz as a 26.6Mhz :

Led blink 950mS and Start bit width 15µS ?

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Tue Oct 14, 2008 12:20 am

Thanks for the .Hex file.
Same result that me with your dsPIC_33f_Explorer16_GP710.hex file.
The start bit is 23µS width, instead 8.5µS, so it's also doesn't work in Rs232Gui

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: UART on DsPic33FJ256MC710

Post by LubinKerhuel » Tue Oct 14, 2008 5:43 pm

Hi,

The problem described is weird!
It is still not clear where it comes from :

- Either there is a bug in the blockset, like an overflow that occurs when using high frequency quartz like 40Mhz quartz
- Neither there is a hardware problem on your system.

As no PLL are used, a 40Mhz quartz gives a 20MIPS system, it is quite straight ! The time step should be fine and the blinking led should blink at the required frequency! You could also do a test with the busy flag port in the MASTER block and check the time step with a scope.
Ender wrote:If I use a C code in Mplab to send a ramp of values with your frame, the GUI display the signal. So I think the hardware configuration is fine.
In other word, the hardware is Ok!

Could you compare the code you write with the code generated by the blockset ? (use the simulink report : Simulation ==> Configuration Parameters ==> Real Time workshop ==> HTML report)
The only part to compare is within the main file: timers and UART configuration...

Or send me your "MPLAB" working code that works with your hardware I will have a look.

Lubin

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Wed Oct 15, 2008 4:54 am

You right Lumbin, I used a example code from Microship which used the PLL.
There is a hardware problem on the oscillator, some time and more when I use the oscilloscope probe the frequency is correct.
I'll replace the capacitors by the new ones to be sure of their values and remove/re-solder the quartz.

If I reuse the original 8Mhz quartz, how the blockset will work if the loop time execution is too long to match with the transfer rate request?
In this case do you use the PLL to increase FCy, the instruction cycle clock, at more than 8Mhz ?

Thanks a lot.

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: UART on DsPic33FJ256MC710

Post by Ender » Wed Oct 15, 2008 5:07 am

Okay, I found the answer myself in master block description.
http://www.kerhuel.eu/RTWdsPIC/Blocks/Master.html

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: UART on DsPic33FJ256MC710

Post by LubinKerhuel » Wed Oct 15, 2008 9:54 pm

Hi Ender,

To complete the topic :
Ender wrote:how the blockset will work if the loop time execution is too long to match with the transfer rate request?
Execution continues (i.e. not like the xPC target system behaviour where the execution hang up)
Ender wrote:In this case do you use the PLL to increase FCy, the instruction cycle clock, at more than 8Mhz ?
This is how it works!
Ender wrote:Okay, I found the answer myself in master block description.
http://www.kerhuel.eu/RTWdsPIC/Blocks/Master.html
This is the old page and will not be updated anymore. Please use this on : http://www.kerhuel.eu/wiki/Block/Master

Lubin

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests