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 support@ccsinfo.com

Problem with Port C - please help

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








Problem with Port C - please help
PostPosted: Wed Sep 01, 2004 3:01 am     Reply with quote

Dear All,
I have a simple program where I'm testing port C. Normally I'm using port C for digital potentiometer, but because of problems described below, I have written this simple program to test it. The problem is that when I'm running this program with delay_us(1...1000) PIN_C1 is not working. Is alwayes high. When I'm changing delay to delay_ms(2...10 and up) PIN_C1 is starting to run properly. However for smaller delays, checking with my osciloscope I saw that it is not exactly squere wave, it is rathe tringle wave, and increasing delay it is going to be square wafe. I know that port C need to be especially used, but I not really understand how. I check all possible messages in this forum. Could you please help me just to generate a squere wave in this selected port C pins. Interesting is that problem is only on PIC_C1, other pins are working fine. I have one of the latest version of CCS compiles 3.06. Many thanks John

while(1){
output_low(PIN_C0);
delay_us(5);
output_low(PIN_C1);
delay_us(5);
output_low(PIN_C2);
delay_us(5);

output_high(PIN_C0);
delay_us(5);
output_high(PIN_C1);
delay_us(5);
output_high(PIN_C2);
delay_us(5);
}
Ttelmah
Guest







Re: Problem with Port C - please help
PostPosted: Wed Sep 01, 2004 3:21 am     Reply with quote

Anonymous wrote:
Dear All,
I have a simple program where I'm testing port C. Normally I'm using port C for digital potentiometer, but because of problems described below, I have written this simple program to test it. The problem is that when I'm running this program with delay_us(1...1000) PIN_C1 is not working. Is alwayes high. When I'm changing delay to delay_ms(2...10 and up) PIN_C1 is starting to run properly. However for smaller delays, checking with my osciloscope I saw that it is not exactly squere wave, it is rathe tringle wave, and increasing delay it is going to be square wafe. I know that port C need to be especially used, but I not really understand how. I check all possible messages in this forum. Could you please help me just to generate a squere wave in this selected port C pins. Interesting is that problem is only on PIC_C1, other pins are working fine. I have one of the latest version of CCS compiles 3.06. Many thanks John

while(1){
output_low(PIN_C0);
delay_us(5);
output_low(PIN_C1);
delay_us(5);
output_low(PIN_C2);
delay_us(5);

output_high(PIN_C0);
delay_us(5);
output_high(PIN_C1);
delay_us(5);
output_high(PIN_C2);
delay_us(5);
}

This sounds like a hardware problem, not a software one. The suspicion is that there is a significant capacitance attached to pin C1, and hence the output is a slow 'slew', as this charges/discharges. You don't say what chip is involved, but in some cases specific pins have other functions, and this would need to be checked.

Best Wishes
Guest








Re: Problem with Port C - please help
PostPosted: Wed Sep 01, 2004 3:31 am     Reply with quote

I'm using 18F452, I thought that it was hardware problem, but to isolate it, i desolder those pins, and make my test againg - same result.

John
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Sep 01, 2004 8:28 am     Reply with quote

Maybe you could post your entire test program, including #fuses and other statements. It would be helpful to see how you are setting the PIC up.

Ronald
Guest
Guest







Port C
PostPosted: Wed Sep 01, 2004 9:52 am     Reply with quote

Don't know what kind of scope probes you are using, but if they are of low quality (high capacitance), they may distort the actual signal you are trying to look at. You may also check the o'scope coupling settings and see how your signal changes with different settings. Make sure the scope probe gnd is really ground too.

On more than one occasion I was scratching my head looking at the code when I was really facing a hardware problem.

Just my two cents.....
Guest








PostPosted: Wed Sep 01, 2004 12:33 pm     Reply with quote

Hi,

I'm using HP Infinium DSO 2 GS/S 500MHZ with original probes. This not a problem with my DSO, connected digital pot is not working. I tryed also another example to send without any delay 0xff to port C, same result.
Find some parts of my software


#include <18F452.h>
#case // Make the compiler case sensitive (as most are)


#device adc=8
#device *=16
//#use delay(clock=8000000)
#use delay(clock=32000000)
#id checksum // The default part ID will be the program memory checksum

#fuses H4,NOWDT, NOPROTECT, PUT, NOLVP
#zero_ram

#opt 11


-----------------

//***********************************************************************************
#separate
void set_pot( unsigned char value)
{




unsigned char i;
unsigned char dpot[2];
// 0b00010001 0x11 Write data to DPOT 1
// 0b00100001 0x21 Shutdown DPOT 1
dpot[0] = value;
dpot[1] = 0x11;

//#use fast_io(C)
//#byte TRISC = 0x94
//byte port_c_temp;

//port_c_temp=TRISC;
//bit_set(port_c_temp,1);
//set_tris_c(0x00);
//set_tris_c(port_c_temp);



#USE fast_io(C)
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);

while(1){
set_tris_c(0x00);
output_c(0xFF);
// delay_us(5);
set_tris_c(0x00);
output_c(0x00);
// delay_us(5);
}


while(1){
output_low(SCK);
delay_us(5);
output_low(CSPOT);
delay_us(5);
output_low(SDO);
delay_us(5);

output_high(SCK);
delay_us(5);
output_high(CSPOT);
delay_us(5);
output_high(SDO);
delay_us(5);
}


output_low(SCK);
output_low(CSPOT); // Select DPOT
delay_us(10);
for(i=1;i<=16;++i)
{
output_bit(SDO, shift_left(dpot,2,0));
delay_us(10);
output_high(SCK);
delay_us(10);
output_low(SCK);
delay_us(10);
}
output_high(CSPOT); // de-Select DPOT


}


best regards
John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 01, 2004 12:57 pm     Reply with quote

This test program that you've posted is way too complicated.
Your goal is to find out why you can't control Pin C1.

I would do this:

1. Get rid of the H4 fuse and the 4x PLL mode. Just set it to HS and
set the #use delay() to 8 MHz.

2. Get rid of the #separate and the #case.

3. Get rid of the #opt 11. Using high opt levels is practically
begging for bugs. I would never do it in a regular program
and certainly not in a test program. If anything, you should be
reducing the #opt level to 5.

4. Get rid of the #fast_io and tris statements. These may be causing
the problem, so you may want to add them back in later.

5. Get rid of all code that's not needed to test the Pin C0 problem.

6. You said you have vs. 3.06 of the compiler. I assume you mean
vs. 3.206 ? To me, that's still semi-beta or beta after the changes
done to create the 3.2xx series. Having the latest compiler is not
necessarily good. If you haven't done so already, go to the CCS
download page and get vs. 3.191. If your update period has just
run out (I assume you recently bought the compiler), then email
CCS and explain that you didn't realize that you were supposed to
download vs. 3.191 as well, and they will probably extend your
download rights by 1 day to let you get it. Once you have it, then
install it and see if it solves the problem.
Guest








PostPosted: Wed Sep 01, 2004 1:15 pm     Reply with quote

thanks for your advices,
i'm following them, soon infor about results
rgds
john
Guest








PostPosted: Wed Sep 01, 2004 5:43 pm     Reply with quote

After some hours ...
Seems to pronblem with soldering. On other boards (similar) it is working.
Many thanks for your help
rgsds
John
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