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

ADC Problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 4:11 pm     Reply with quote

Did you know that MPLAB has PicKit2 support ? It's built in. You don't
have to use the separate program. But anyway, those checkboxes
look like they do the same thing as the MPLAB buttons do.

I think the most likely reason for those checkboxes working or not working
might be that some programs are compiled with the NOMCLR fuse setting.
In that case, the checkboxes won't do anything.
Got-Got



Joined: 26 Feb 2012
Posts: 17

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 4:39 pm     Reply with quote

I didn't know for pickit 2 programmer in mplab. Thanks.
And you are right for the fuses. In the other programs, nomclr is here...
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 11:45 pm     Reply with quote

Do not use MPLAB, use ccs ide and forget troubles. MPLAB is doing such dodgy things that you have no control over the code, when I have moved to ccs ide then I have learnt how much wrong was in my code and why it was unpredictable.
_________________
Help "d" others and then you shell receive some help from "d" others.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 12:27 am     Reply with quote

Please explain how people who use MPLAB as the IDE for the CCS
compiler have no control over their code. The user writes the C source.
The compiler compiles it. MPLAB then programs it into the PIC. Where's
the lack of control ?
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 12:45 am     Reply with quote

I have found that MPLAB is sometimes on occasions trying to fix broken code instead of showing the problem, ccs ide is showing the problem and is not trying to fix anything. So MPLAB is confusing the user because the user cannot learn where are mistakes made. Mainly it applies to trying to fix wrong order of commands. When I have moved my code written in MPLAB to ccs ide then I have found that it didn't work. Code was written over 2 years and I had such problems with it that it is hard to believe, I could not find errors and nobody could help me. Code was slow and unstable, sometimes moving a block of code up or down could crash the pic. CCS ide did show up front errors in structure of the code and command order. That is all, so if there are issues and everything should work but is not than it may be an issue with MPLAB itself. It is preparing the code before it sends it to compiler and it does not do it properly. Since I use CCS ide I have no issues with the code at all. To take as an example ADC functions the same code compiled on CCS IDE was returning great readings, MPLAB was returning chaos, on occasions jumping way up or down so much that I could not use ADC and had to do 50 readings and then calculate average based on it. And most of problems with my ADC was actually MPLAB itself. That is all. Next thing I have found is that one in few programs and compilations of the code is corrupted on regular bases and I needed to remove everything autogenerated by MPLAB from MPLAB and source folder and then build it up again and the same code was working but a moment ago didn't. Next issue was related to clearing rom on pic, the same story, I had to clear it on regular bases to make sure that the code is fresh and new generated. Since I use CCS IDE never ever experienced anything like that. MPLAB was in use for over 2.5 years on daily bases, CCS is in use for half year now, dos command used to control pickit 2 and all works like a charm, if something does not work then it is me. Then I have shared my experience with my friend who is lets say 30years ahead of me in C and pics and the first thing I was told was to stop using MPLAB. I hope it helps.
_________________
Help "d" others and then you shell receive some help from "d" others.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 1:06 am     Reply with quote

I don't know. I don't understand your reply. I believe we are somehow
talking about different things. For example, I have no idea what this
means at all:
Quote:

I have found that MPLAB is sometimes on occasions trying to fix broken
code instead of showing the problem,

How can a mere text editor (ie. MPLAB) fix anything ?
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 1:23 am     Reply with quote

This question is for MPLAB not me, if CCS IDE is not processing the code from MPLAB then it is not right. Do not take it as a rule but as a possibility. That is my experience only and may not repeat on different hardware. Just a hint nothing more.
_________________
Help "d" others and then you shell receive some help from "d" others.
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 1:31 am     Reply with quote

void main(){
int8 temp=0;

SETUP_ADC_PORTS(sAN0 | VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL); //configuring ADC

Quote:
setup_adc_ports(ALL_ANALOG); // Ports in ADC
-> this does not need to be here, u got it above


while(true){ //forever
set_adc_channel(0);// AN0 reading
delay_us(20);// 20us delay
temp=read_adc(); // AN0 reading: 0<=temp<=255

// turn led on if "temp" >100

Quote:
if(temp > 100){
-> print out this value to see it you ever reach it


output_high(PIN_D7);
delay_ms(500); // waiting half second
}
else{
output_low(PIN_D7);
}
}
}
_________________
Help "d" others and then you shell receive some help from "d" others.
Got-Got



Joined: 26 Feb 2012
Posts: 17

View user's profile Send private message

PostPosted: Wed Feb 29, 2012 1:30 pm     Reply with quote

How could I print out this value, Linuxbuilders?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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