It is currently 22 Apr 2018 13:32

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 08 May 2017 17:17 
Offline

Joined: 18 Jun 2014 11:59
Posts: 7
Hi,

i have one master processor (dsPIC30F6014A). There are 5 Sleave processors.(4 for dsPIC30F4013, 1 for PIC16F883.)
I communicated with those for dsPIC. But I could not communicate with the one for PIC.
I use the command: RS485Slave_Init and RS485Master_Init...

I am using the UART1_Init (9600) command for those for DsPIC. And there is no problem.
But there is a problem with the PIC. The program is going to UART interrupt. But the receive data are not true.

Is there a different method?

Note: Master MCU(dsPIC30F6014A) Freq= 60Mhz internal,
Sleave dsPIC304013 MCUs Freq = 60Mhz internal,
Sleave PIC16F883 MCU Freq = 8Mhz internal


Master Code:
Procedure Initialize;
 begin
      UART2_Init(9600); // comm speed
      Delay_ms(100);
     
      Rs485master_Init();
      Delay_ms(100);
 end;






Sleave Code:
Procedure Initialize;
 begin
      UART1_Init(9600); // comm speed
      Delay_ms(100);
     
      RS485Slave_Init(Sleave_Addr);               // Intialize MCU as slave, address 0x04
      Delay_ms(100);
 end;





Top
 Profile  
 
PostPosted: 09 May 2017 16:52 
Offline
User avatar

Joined: 21 Mar 2017 16:57
Posts: 527
Hello,

As far as I have understood, you are getting a garbage on the PIC side, right ? Garbage data is most often a result of difference in data rate setup. Also, if the clock of the PIC is not set up properly, it can cause erratic data being sent too. Make sure you are using the correct clock settings for the PIC. Since the both data rates are set the same, I suspect that the clock on the PIC is not set correctly.

Best regards


Top
 Profile  
 
PostPosted: 09 May 2017 18:59 
Offline

Joined: 18 Jun 2014 11:59
Posts: 7
darko.ilijevski wrote:
Hello,

As far as I have understood, you are getting a garbage on the PIC side, right ? Garbage data is most often a result of difference in data rate setup. Also, if the clock of the PIC is not set up properly, it can cause erratic data being sent too. Make sure you are using the correct clock settings for the PIC. Since the both data rates are set the same, I suspect that the clock on the PIC is not set correctly.

Best regards

Thank you very much. i will check. But, How should i set up the oscillator?


Top
 Profile  
 
PostPosted: 10 May 2017 16:44 
Offline
User avatar

Joined: 21 Mar 2017 16:57
Posts: 527
Hello,

You should go to the PIC compiler and see if here is some "schemes" availabe at the PROJECT > EDIT PROJECT for that particular MCU. Schemes are stored config settings for different MCUs. If there is no pre-made scheme, you should take the datasheet of the MCU and study it for the proper settings. Then you can edit the settings in your EDIT PROJECT window

Best way to check if the clock is set correctly is to make a simple loopback UART example and test it with the UART terminal. You can write back to UART, after you read from the UART. If it returns the data correctly - then your clock settigns and baud rate is good. Another 'crude' way to test your clock would be a LED blink example : if you set up the LEDs to blink on a port with the delay_ms(500); and you see it takes longer than half a second, you know the clock is not good. Of course - more "academic" solution would be to use the clock config mode, which sets up an CLKOUT pin so you can measure the frequency on the oscilloscope - e.g. INTOSC oscillator mode.

A hint : OSCCON = 0x71; should force internal oscillator at 8 MHz regardless of config settings.

Best regards.


Top
 Profile  
 
PostPosted: 10 May 2017 19:59 
Offline

Joined: 18 Jun 2014 11:59
Posts: 7
darko.ilijevski wrote:
Hello,

You should go to the PIC compiler and see if here is some "schemes" availabe at the PROJECT > EDIT PROJECT for that particular MCU. Schemes are stored config settings for different MCUs. If there is no pre-made scheme, you should take the datasheet of the MCU and study it for the proper settings. Then you can edit the settings in your EDIT PROJECT window

Best way to check if the clock is set correctly is to make a simple loopback UART example and test it with the UART terminal. You can write back to UART, after you read from the UART. If it returns the data correctly - then your clock settigns and baud rate is good. Another 'crude' way to test your clock would be a LED blink example : if you set up the LEDs to blink on a port with the delay_ms(500); and you see it takes longer than half a second, you know the clock is not good. Of course - more "academic" solution would be to use the clock config mode, which sets up an CLKOUT pin so you can measure the frequency on the oscilloscope - e.g. INTOSC oscillator mode.

A hint : OSCCON = 0x71; should force internal oscillator at 8 MHz regardless of config settings.

Best regards.


Hi,

Thank you, i will check.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: