• AVR Freaks

Helpful ReplyHot!Code is build and programmed Successfuly but not working in PIC32MX795F512H.

Page: 12 > Showing page 1 of 2
Author
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
2020/09/30 13:09:51 (permalink)
0

Code is build and programmed Successfuly but not working in PIC32MX795F512H.

Hello,
I have wrote a code for  PIC32MX795F512L which is running successfully on the Evaluation board diligent MAX32. Now I have designed my own board with PIC32MX795F512H mc and changed the code accordingly. The Microcontroller programmed successful with the code but it is not running. 
Even LED blink program is not running. I have doubts about Crystal Oscillator. In reference to design, there was a 30pf capacitor connected on OSC1 and OSC2. I have used 33pf, later 10pf, and even with no capacitors. But the program is not working. I am using Harmony 3. Could someone help me with the issue? Also, can anybody explain how to turn on the Internal oscillator to check whether the microcontroller is functioning or not??? 
#1
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/09/30 14:09:12 (permalink)
5 (1)
Discarding the theory that the crystal isn't properly soldered to the PCB or that it is damaged.
 
You should try to make it work with the internal oscillator.
 
If you don't know how, it implies that possibly, you are not setting the 'configuration bits' correctly
 
I'm not sure if the crystal oscillates or not when the bits are wrong, possibly that's the reason.
 
You should try to understand what the configuration bits or fuses of an MCU are.
#2
boatbodger
Super Member
  • Total Posts : 132
  • Reward points : 0
  • Joined: 2011/03/27 15:39:07
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/09/30 14:24:20 (permalink)
0
Have you use the Tools/Clock Configuration feature of Harmony 3 to set the oscillator configuration?
#3
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/09/30 14:31:30 (permalink)
0
boatbodger
Have you use the Tools/Clock Configuration feature of Harmony 3 to set the oscillator configuration?


Harmony Configurator:

https://pbs.twimg.com/media/EjMHBWBXcAE6aFl?format=png&name=large


In the images of the schematic (apart from being of very low resolution) it is not shown what frequency the crystal is, nor how it is connected.
 
You should also share how the configuration bits are set.
 
And again. Why don't you try switching to the internal RC oscillator?
 
#4
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 01:27:10 (permalink)
0
The microcontroller is oscillating on the internal Crystal Oscillator but even it is not working.
post edited by m_snaeem@hotmail.com - 2020/10/01 01:28:52

Attached Image(s)

#5
ric
Super Member
  • Total Posts : 28660
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 02:36:29 (permalink)
0
m_snaeem@hotmail.com
The microcontroller is oscillating on the internal Crystal Oscillator...

How do you know?
What did you do to select the internal oscillator, and how did you verify that it worked?
 
post edited by ric - 2020/10/01 02:37:35

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#6
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 02:44:09 (permalink)
0
I have selected in the setting so this is how i am saying it is oscillating on an internal Oscillator. I have changed FNOSC value to FRC and it works. Also with External oscillator with proper soldering now.
But still it is very slow with both FRC and External oscillator. It toggles LED in 6 or 7 seconds where its toggle time is set as 1000ms. Can you help me further?


#7
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 04:47:53 (permalink)
0
m_snaeem@hotmail.com
I have selected in the setting so this is how i am saying it is oscillating on an internal Oscillator. I have changed FNOSC value to FRC and it works. Also with External oscillator with proper soldering now.
But still it is very slow with both FRC and External oscillator. It toggles LED in 6 or 7 seconds where its toggle time is set as 1000ms. Can you help me further?




And what happens when you try to debug or simulate the project?
#8
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 04:51:39 (permalink)
0
It debugs successfully but as there is not proper clock so UART received wrong command and my code does not work properly.
#9
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 04:58:18 (permalink)
4 (1)
m_snaeem@hotmail.com
It debugs successfully but as there is not proper clock so UART received wrong command and my code does not work properly.


If you say debug, it implies that if this internal oscillator works correctly. If you say that you get wrong data in the UART, possibly you are wrong setting the speed of sending and receiving data, that speed depends on the frequency of oscillation. For example, let's say that you want it to work at 9600 bps, but if it is wrongly configured, that speed may be higher or lower than what you want.
#10
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 05:05:07 (permalink)
0
Yes it internal oscillator work correctly but default slow speed(i think). I have assigned a 40Mhz plib clock which i think is not being generated. As a core timer, i have set at 1000ms to toggle LED but it take 10 or 11 seconds to toggle LED which means it is not getting 40MHz frequency.
#11
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 05:09:11 (permalink)
0
m_snaeem@hotmail.com
Yes it internal oscillator work correctly but default slow speed(i think). I have assigned a 40Mhz plib clock which i think is not being generated. As a core timer, i have set at 1000ms to toggle LED but it take 10 or 11 seconds to toggle LED which means it is not getting 40MHz frequency.


The Core timer has no relation to the PBCLK. You should look for core timer information in the datasheets.
#12
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 05:12:04 (permalink)
0
m_snaeem@hotmail.com
Yes it internal oscillator work correctly but default slow speed(i think). I have assigned a 40Mhz plib clock which i think is not being generated. As a core timer, i have set at 1000ms to toggle LED but it take 10 or 11 seconds to toggle LED which means it is not getting 40MHz frequency.


And you should share the parts of the code that you say doesn't work to try to understand what you want to do and possibly find out what is wrong.
#13
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 05:34:20 (permalink)
0
I have written this simple to code to test microcontroller timer
 
while (true) {
for(int i=0 ; i<20 ; i++)
{
delay_10ms();
}
LED_Toggle() ;

// CORETIMER_DelayMs(1000);
}
 
 
//////////////////////////////////////////////////////
void delay_10ms()
{
TMR5_Start() ;
while(TMR5_CounterGet() < 1560) ;
TMR5_Stop() ;
TMR5 = 0x0;
}
//////////////////////////////////////////////////////////
and it is not working
#14
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 05:47:24 (permalink)
0
void delay_10ms()
{
TMR5_Start() ;
while(TMR5_CounterGet() < 3998) ; //maximum count 3999 to generate 1ms
TMR5_Stop() ;
TMR5 = 0x0;
}
 
int Main()  {
while (true) {
for(int i=0 ; i<200 ; i++)
{
delay_10ms();
}
LED_Toggle() ;

// CORETIMER_DelayMs(1000);
}
}
 
This code is supposed to generate a square wave of 4 second duty cycle but it is generating 1 secondduty cycle square wave so clock is false slow or fast that does not matter 
#15
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 06:06:04 (permalink)
0
The External oscillator as well as internal oscillator work properly at 8Mhz but when i try to get FRCPLL or external clock PLL which is 80Mhz clock i get nothing.
#16
NorthGuy
Super Member
  • Total Posts : 6350
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 07:15:06 (permalink) ☄ Helpfulby m_snaeem@hotmail.com 2020/10/02 13:21:40
5 (1)
So, the PLL doesn't work.
 
There are 4 possibilities I can see:
 
- You misconfigured PLL
- You're doing clock switching incorrectly
- Not enough power to run PIC at higher speed
- Very bad bypassing (e.g. no bypassing capacitors at all)
#17
m_snaeem@hotmail.com
Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2020/07/10 10:54:03
  • Location: 0
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 07:30:04 (permalink)
0
Power is enough up to 500 mA, and the Microcontroller is getting 50 to 60mA.
Every Power pin has a bypass capacitor of 100nF,
PLL is configured in Harmony so no doubt about it what do mean by Clock switching???
#18
DominusT
Super Member
  • Total Posts : 1456
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 07:47:13 (permalink)
0
m_snaeem@hotmail.com
void delay_10ms()
{
TMR5_Start() ;
while(TMR5_CounterGet() < 3998) ; //maximum count 3999 to generate 1ms
TMR5_Stop() ;
TMR5 = 0x0;
}
 
int Main()  {
while (true) {
for(int i=0 ; i<200 ; i++)
{
delay_10ms();
}
LED_Toggle() ;

// CORETIMER_DelayMs(1000);
}
}
 
This code is supposed to generate a square wave of 4 second duty cycle but it is generating 1 secondduty cycle square wave so clock is false slow or fast that does not matter 


And what is the prescaler of timer 5? How is the configuration of the tmr5? Are you sure that with that value 10 ms is generated?
#19
NorthGuy
Super Member
  • Total Posts : 6350
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: Code is build and programmed Successfuly but not working in PIC32MX795F512H. 2020/10/01 08:06:39 (permalink)
5 (2)
m_snaeem@hotmail.com
PLL is configured in Harmony so no doubt about it ...



You're far too trusty.
 
m_snaeem@hotmail.com
...what do mean by Clock switching???

 
If you start with a non-PLL clock and then switch to PLL.
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2020 APG vNext Commercial Version 4.5