Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16f88

Status
Not open for further replies.

trexter711

New Member
Hi, it's my first time that I'm using the 16F88 and I'm having trouble with it.
You will find the source code attached.
I'm having the outputs flashing randomly.
Can anyone help me.

Thanks.
 

Attachments

  • 16F88.txt
    2.8 KB · Views: 233
Might be a good idea to use the MicroChip include files?, instead of trying to write them out - also add the destination suffixes to the instructions that require them, otherwise the assembler will use the default setting (which may not be what you want).
 
Are you using an IDE or MPLAB? If so, its better to use the included
INCLUDE "P16F88.INC" directive so that you have immediate access to all the registers available for the device without need of manually declaring each one by one and possible setting the wrong constant.

You may need to insert some delay time before graping the next a2d value, else the LEDs could look constantly on. What is your randomization source, two pots and two hands?

Your ADRES is pointing to ADRESH, which would be ok of you want to access ADRESH. Instead use a clear variable because the a2d result is stored in both ADRESH and ADRESL. It appears (not sure) you have configured the ADRES to be right justified so that you will only use it as 8-bit instead of 10-bit. So you actually need to be accessing ADRESL instead of the current ADRES which points to ADRESH.

Your ADCON is pointing to ADCON0. You need to access both ADCON0 and ADCON1 to properly configure the a2d module. Currently ADCON does toggle batch and forth between AN1 and AN2. I had to scan back and forth between your code and the P16F88.INC file just to make sure, hence why there are two post above my post making me look like a repeater :)
 
Last edited:
while, I agree with the other responders - use existing header files - I suspect your problem is just logic. Instead of trying to debug your existing code, I would strip it down to a delay loop and toggle an led on/off. Once you get that working, then add back in the ADC code. A methodical approach is probably easier than trying to debug everything at once - multiple bugs make it harder to isolate a single problem.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top