CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with 24FJ64GA306's port D

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Problem with 24FJ64GA306's port D
PostPosted: Wed Mar 12, 2014 6:38 am     Reply with quote

Greetings! I'm using MPlab v 8.91, CCS v4.134 and PIC24FJ64GA306. I have pull-up resistors(6k) on several port D pins. I have strange glitch. In one of three-four power-ups the pins don't work - like they are not set properly. They stayed in high voltage condition in spite of they have to be low. Like the TRIS D is not set properly.
I tried to change output_drive(PIN_N) with *0x02D8=
but the glitch stays!
I changed Vcap - no difference.
Where could be the problem?!
Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 12, 2014 9:50 am     Reply with quote

Could easily be another peripheral on those pins.
Without seeing your entire test code, can't tell is you've disabled devices like ADC,comp,UARTS,'debug', etc. that might be on those pins.
Also 'random' could mean marginally power supply so fuses like PUT shout be set, to allow PIC to 'get organized' before the real code executes.


hth
jay
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Wed Mar 12, 2014 10:33 am     Reply with quote

There are parts of my code:
Code:

#include <24FJ64GA306.h>
#FUSES HS,WDT_SW,WPOSTS8,PR
#use delay(clock=20M)
#use I2C(MASTER,SCL=PIN_G2,SDA=PIN_G3,FORCE_SW)

The code is large, but there are only calculations. I`m using only I2C and timers 2 and 3. I`m counting time with them - I don`t use pulse generation. I`m using the RTC.
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Mar 12, 2014 12:49 pm     Reply with quote

What you were being asked, is what code you have to setup the peripherals.

The point is that the 'PORT D' functions on these pins, are the _lowest_ priority. The top is the relocatable peripheral functions (which shouldn't apply unless you have something selected to these pins), then the LCD segments (what code do you have controlling this?), then the parallel master port (what code again?). Only at the end, the port functions....
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 12:58 am     Reply with quote

OK! Here is my conde controlling port D:
Code:

void SetPinsToInput()
{
   output_float(DATA_pin0);
   output_float(DATA_pin1);
   output_float(DATA_pin2);
   output_float(DATA_pin3);
   output_float(DATA_pin4);
   output_float(DATA_pin5);
   output_float(DATA_pin6);
   output_float(DATA_pin7);
}

void SetControllPins()
{
   *0x02D8=0x0EFF;
   /*
   output_float(incomeData);
   output_drive(dataRecieved);
   output_float(demandData);
   output_low(dataRecieved);
   */
}

I don`t use LCD and master port, so I haven`t use any command for them. Do I have to stop them somehow?!
This is my entire program now:
Code:

#include <24FJ64GA306.h>
#FUSES HS,WDT_SW,WPOSTS8,PR,NODEBUG,NOIOL1WAY,BROWNOUT
#use delay(clock=20M)
#use I2C(MASTER,SCL=PIN_G2,SDA=PIN_G3,FORCE_SW)

void main()
{
     delay_ms(2000);
     SetPinsToInput();
     SetControllPins();
     while(1);
}

I have the same problem again!
Pin which has to be low stays high.... In 1 of 5 power-ups!
Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 5:50 am     Reply with quote

While I don't use the 24 series PICs, this comment applies to all PICs.
You MUST disable any and ALL peripherals using any I/O pin you want to use for digital I/O.
Unfortunately when a PIC powers up in the default configuration,several I/O pins will be setup for ADC,comparators,UARTS, etc. Unless you specifically disable them, they will 'override' or conflict with regular 'I/O' operations.

Write a very small,complete compilable program and show us.Main() just needs to 'toggle' the I/O pins of interest,so it'll be 15-20 lines of code.
As this PIC has programmable pin select, there might be a problem there,showing us this small program will confir/deny this.

hth
jay
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 6:00 am     Reply with quote

I ran a LED test. I connected LED on pin F6. This is the program:
Code:

#include <24FJ64GA306.h>
#FUSES HS,WDT_SW,WPOSTS8,PR,NODEBUG,NOIOL1WAY,BROWNOUT
#use delay(clock=20M)
#use I2C(MASTER,SCL=PIN_G2,SDA=PIN_G3,FORCE_SW)

void main()
{
   delay_ms(5000);
   output_drive(PIN_F6);
        while(1)
         {
      output_high(PIN_F6);
      delay_ms(1000);
      output_low(PIN_F6);
      delay_ms(1000);
         }
}

The glitch continues! The LED doesn`t start blinking in 1 of 5-6-7 starts.
Any suggestions?!
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 7:22 am     Reply with quote

How is the LED connected to your PIC, and have you checked your anticipated LED current vs the PIC's output drive/sink current spec?
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 8:22 am     Reply with quote

Everything is correct! 1.3V LED with 220 ohms resistor. 10mA current.
In debugger mode when the problem happens the debugger doesn`t start. It stays in this row:
Code:

#use delay(clock=20M)

Like there is no oscillator. I`ll change the quartz and the caps tomorrow. I`ll resolder the traces. I hope this to fix it. Do I have to think about a resistor in the quartz circuit?!
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 12:28 pm     Reply with quote

hmm..debugger... I never use it.. but am aware that 'it' will configure the PIC the way IT wants to, not necessarily the way YOU do.
also look into the 'fail safe oscillator' section(if it has it)...

I'm still not seeing any 'disabling' of peripherals in your code or 'pin select' mapping. Others who use the 24 series can help better.
I do know there have been a few posts about them,maybe check them all for a 'set of working fuses', basic setup to confirm the '1 Hz LED test'.

hth
jay
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Thu Mar 13, 2014 12:47 pm     Reply with quote

stoyanoff wrote:
Everything is correct! 1.3V LED with 220 ohms resistor. 10mA current.
In debugger mode when the problem happens the debugger doesn`t start. It stays in this row:
Code:

#use delay(clock=20M)

Like there is no oscillator. I`ll change the quartz and the caps tomorrow. I`ll resolder the traces. I hope this to fix it. Do I have to think about a resistor in the quartz circuit?!


Read this, it may be applicable: http://www.ccsinfo.com/forum/viewtopic.php?t=47757&highlight=dspic%2A+crystal

My standard dsPIC33FJ crystal circuit incorporates a 160R series resistor (which was established after some trial & error).
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sat Mar 15, 2014 9:37 am     Reply with quote

I fixed the problem. Or think so! I changed the power supply. Till now I was using pulse voltage regulator LM2575. I separated the controller on independent circuit with LM317 regulator.
Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 15, 2014 12:13 pm     Reply with quote

It shouldn't matter whether you use a linear or switching type regulator for the power supply. What does matter is the correct design for the load.Switching types are 'noisy' and you must filter the output accordingly.
Proper layout of grounds, and bypass caps is very important as well.
Since your 'cure' was to go 'linear', I suspect either poor power supply design or 'noise' getting to the PIC.
An oscilloscope on the power lines at the PIC would be informative.

I usually 'overkill' power supply designs by a factor of 5, more if inductive loads (relays,lamps, etc.) are used.


hth
jay
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Sat Mar 15, 2014 1:21 pm     Reply with quote

I did the schematic by book - as the datasheet says. I have 2 more microcontrollers on the same pulse power supply -16F66J60. None has such problem. Only this one which is on the greatest distance -10 centimeters.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group