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

ADC on Pic16F88 not working
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
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:31 am     Reply with quote

Tris A A0 is input the rest is output! Yes INT RB is being called. I tested on my development board and it is working right apart the ADC.
Ttelmah



Joined: 11 Mar 2010
Posts: 20058

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:36 am     Reply with quote

No.
You misunderstand The behaviour of some instructions.

Yes, the line:

set_tris_a(0b0000001); //switches A0 to be an input

Sets A0 to be an input, but the very next line:

output_a(0b0000000);

Sets the _whole_ of PortA to be outputs.

A byte wide output in standard_io mode, sets the TRIS as well as the output latch....
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:37 am     Reply with quote

this is the pot resistance to PIC. I made the drawing on Proteus, and made no software simulation.

https://ibb.co/jaQ3z5

I just need that when the wiper is 5V it give 254 and GND it gives 0.
Ttelmah



Joined: 11 Mar 2010
Posts: 20058

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:40 am     Reply with quote

I know what a B***p pot looks like.....

Read what you are being told, or just try it. You are incorrectly overriding the port directions, which is why the code won't work....
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:44 am     Reply with quote

seems that that was the problem. Now it is working! I made the

Code:
output_b(00000000)


to clear all the output to be 100% safe
Ttelmah



Joined: 11 Mar 2010
Posts: 20058

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:56 am     Reply with quote

Yes. It is perfectly fair to do so. but you then need to set the TRIS _afterwards_ to the value you require.

An 'output_x' sets everything in the port 'x' to output.....
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 6:57 am     Reply with quote

thanks...I learned something new. Thanks for this clarification..
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Aug 21, 2017 7:02 am     Reply with quote

I would like to take this opportunity to thank to those to help me to solve this problem. Perhaps for some of you it was a silly question, but for me it was very important to continue with my project. Once again thanks for your time and effort to help me, although you do not know me.
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