Well, when a pin is configured as an analogue pin it works very well as a digital output - there is no analogue output mode. When you read it, it always reads zero unless you turn the analogue part off. So, x=~x will always write a 1 to any pins configured as analogue.
Just can't toggle them LOL I was just trying the posters code and what millwood posted on what I had plugged in my bread board. When It didn't work on portC I read the data sheet and the chip I have has adc on portC. What Mike said always works for me.
If PORTC=~PORTC doesn't work then some possible reasons are,
1. You have the pins still set to analogue as pointed out by Burt.
2. You have overloaded the pins and this is forcing them high/low. Normally by connecting LEDs without series resistors.
3. You forgot to switch the pins to output.
4. The pins are configured for some other peripheral.
5. One of the other reasons for pics not working - not programmed, no oscillator, no power etc.
Just can't toggle them LOL I was just trying the posters code and what millwood posted on what I had plugged in my bread board. When It didn't work on portC I read the data sheet and the chip I have has adc on portC. What Mike said always works for me.
Most of the time it always 1. or 4. like Mike posted
There a lot of people that ask why this not working and it most all ways because they left
the PORT set as analogue. Then when you make the pin high it come on but will not go back off lol. I didn't no that my chip had it on PORTC and I was using ADC on PortA
All ways need to read the data sheet.
If you read the data sheet you would see that any pin that is configured as analogue but set to output will act as a digital output. However, if you try to read it you will get zero rather than the last value written.
BTW, it was you that started the writing to analogue pins with your PORTC=~PORTC.
Also, I wasn't mad. I just couldn't be bothered writing an explanation when some research by yourself would have answered your question. As it happens, answering the question would have been easier.
let's try it one more time: under what circumstance would you envision writing to an analog (input) pin? what kind of purpose do you expect out of that?
However, if you try to read it you will get zero rather than the last value written.
this goes to incorrect port / pin configuration. It is always prudent to explicitly set the ports appropriately so you don't run into issues like this.
it is kind like you crank the engine in a car without gas and you blame the key for the problem.
the code X=~X will always work, as long as you set the ports correctly - which is a given.
if you can post your code, maybe we can help fix the port configuration.
I have run out of ways to explain this, I've tried the "idiots guide to ..." approach, the quote the data sheet approach and the "put it in simplest terms approach" and you just can't grasp it.
One last try,
It is bad practice to set pins to output and to write to them when they are configured as analogue. You presented code earlier in this thread that did just that. I have since been explaining why your code doesn't work. You obviously haven't consulted a data sheet as you keep repeating the same stupid question.
It's bedtime for me. If you still don't understand it in 8 hours time then please reread this thread or consult a data sheet.
I don't need any code fixed lol How many time do I have to say this I no why it wasn't working I no it should of worked I was trying your code you posted and the poster code to see what happen then you run it and what made it not work He had to have the PORTS set wrong and then you post the toggle so I tried it and the led wouldn't blink on portC so i read the data sheet to see what was on portC and it had ADC on it to turned adc off and all is well LOL
Are you all right
1. I didn't start this thread
2. I didn't write the code that was posted
3. All I did was try the poster code
4. And your code
5. I posted why it didn't run.
6 I said this on page 2 PORT configuration are wrong
And now we have a baby show of who is right and wrong I don't no about you
but I was trying to help the poster
Some people are just very oppositional. Some people on here help others, some just argue. If you take a look at the posts a person makes, then soon you see who helps and who argues.