max
Senior Member
Offline
Posts: 321
Thank You
-Given: 1659
-Receive: 52
|
|
« on: December 27, 2020, 11:10:33 11:10 » |
|
Hi,
I am using the following simple program to toggle port-A bits, using ccs 5.078 compiler The port A0 pin is not toggling, permanently high. The hardware have no problem, i.e no short circuit to supply or other pins.
Regards
|
|
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
Thiru09
Cracking Team
Senior Member
Offline
Posts: 327
Thank You
-Given: 395
-Receive: 1184
|
|
« Reply #1 on: December 27, 2020, 11:49:01 11:49 » |
|
Code has no problem, simulated with Proteus (CCS 5.078, cof file). Check your hardware again. Try to test with another port pin (ex: RC0) to verify whether controller is running or not.
Regards, Thiru
|
|
|
Logged
|
|
|
|
h0nk
Senior Member
Offline
Posts: 257
Thank You
-Given: 226
-Receive: 231
|
|
« Reply #2 on: December 27, 2020, 01:16:09 13:16 » |
|
Hello max,
check the contents of the ANSEL and CMCON0 Register. It looks like that the plain IO-function is not enabled. ANSEL should read all zeros and CMCON0 07h. (Datasheet pg. 31)
Best Regards
|
|
|
Logged
|
|
|
|
Thiru09
Cracking Team
Senior Member
Offline
Posts: 327
Thank You
-Given: 395
-Receive: 1184
|
|
« Reply #3 on: December 27, 2020, 02:43:10 14:43 » |
|
This line takes care of that. setup_comparator(NC_NC_NC_NC); Same for ANSEL
Regards Thiru
|
|
|
Logged
|
|
|
|
max
Senior Member
Offline
Posts: 321
Thank You
-Given: 1659
-Receive: 52
|
|
« Reply #4 on: December 27, 2020, 07:19:57 19:19 » |
|
Hi,
Thanks for reply, the hardware is ok. The port pin RA1 is toggling, so the controller is running. I also test the port c pin, working ok. Only RA0 is permanently High, not toggling.
Regards
|
|
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
Thiru09
Cracking Team
Senior Member
Offline
Posts: 327
Thank You
-Given: 395
-Receive: 1184
|
|
« Reply #5 on: December 28, 2020, 05:43:57 05:43 » |
|
Now possibilities narrow down to either specific IC problem or with connected circuit. Can you post cof or hex file?
Regards, Thiru
|
|
|
Logged
|
|
|
|
max
Senior Member
Offline
Posts: 321
Thank You
-Given: 1659
-Receive: 52
|
|
« Reply #6 on: December 28, 2020, 10:28:19 10:28 » |
|
Hi Thiru
See the attached zip file. I think the problem is related to compiler.
Regards
|
|
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
Thiru09
Cracking Team
Senior Member
Offline
Posts: 327
Thank You
-Given: 395
-Receive: 1184
|
|
« Reply #7 on: December 28, 2020, 12:29:45 12:29 » |
|
Hi max,
Your compiled hex/cof is working fine in proteus. (Since 16F684 is not available with me, I am testing with proteus).
I am attaching sample XC8 (v2.30) project here. Please test with the hex file. "\dist\default\production\Projects.production.hex" or Projects.production.elf
I have not enabled ADC function on RA2 for testing purpose. Let us check first with basic settings. Don't bother oscillator configuration. Just test RA0 status
Regards, Thiru
|
|
|
Logged
|
|
|
|
max
Senior Member
Offline
Posts: 321
Thank You
-Given: 1659
-Receive: 52
|
|
« Reply #8 on: December 28, 2020, 06:16:56 18:16 » |
|
Hi Thiru
I tested the hardware with the xc8 hex file, same result as ccs
RA0 High RA1 Toggling RC0 Toggling
Regards
|
|
« Last Edit: December 28, 2020, 06:19:22 18:19 by max »
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
Poty
Junior Member
Offline
Posts: 57
Thank You
-Given: 52
-Receive: 10
|
|
« Reply #9 on: December 28, 2020, 11:20:00 23:20 » |
|
Hi, Max. I had a similar problem with a 18F4620... and it was related to the ANSEL function. You must check that the definition of ADC ports is pretty clear. Check the basic configuration, and, over all that, define EXPLICITELLY which ports are digital and which none. Even if your definition is redundant, it is better an excess... Just make an intensive lecture of the datasheet. As many times as you need to prerfectly understand which ports are ADC by defect.
Be patient, and good luck.
Regards,
|
|
« Last Edit: December 28, 2020, 11:24:43 23:24 by Poty »
|
Logged
|
You can't have your cake and eat it too... except if you do.
|
|
|
h0nk
Senior Member
Offline
Posts: 257
Thank You
-Given: 226
-Receive: 231
|
|
« Reply #10 on: December 28, 2020, 11:57:45 23:57 » |
|
The PIC 16F684 has no output latches and reads data from the input pins. I dont know the CCS-implementation of "output_toggle" but i assume that this function reads its data from the input pin also. If there is too much capacitive load on the pin it would not toggle.
Change your code to:
while(TRUE) { clear_pin(LED1_PIN); clear_pin(LED2_PIN); delay_ms(500); set_pin(LED1_PIN); set_pin(LED2_PIN); delay_ms(500); }
I dont know CCS, so exchange clear_pin and set_pin with the corresponding function of the CCS-library.
Best Regards
P.S.: The 16F684 is not ridiculous overengineered. Simply write ANSEL=0; and CMCON0=7; in your code, as even the datasheet suggeste, and you perfectly done.
|
|
|
Logged
|
|
|
|
max
Senior Member
Offline
Posts: 321
Thank You
-Given: 1659
-Receive: 52
|
|
« Reply #11 on: December 30, 2020, 11:35:47 11:35 » |
|
Hi,
I manage to toggle the A0 pin. I use a shadow var to keep the port status, and output this var to port-A i.e using the function output_a(). This means read-modify-write did not working on A0 pin, while A1 pin is working properly, both A0 and A1 pins have same type of loading.
Regards
|
|
|
Logged
|
Fate arrived and made the conscious unconscious It silenced the activity of life.
|
|
|
Poty
Junior Member
Offline
Posts: 57
Thank You
-Given: 52
-Receive: 10
|
|
« Reply #12 on: January 02, 2021, 02:38:02 02:38 » |
|
Good evening. Datasheet explicitly indicates this: "The ANSEL and CMCON0 registers must be initialized to configure an analog channel as a digital input. Pins configured as analog inputs will read ‘0’." I´m not familiar with mcc, but as I understand from datasheet, you have to configure ANSEL and CMCON0 to define A0 and A1 as digital ports, and then configure TRISA to define this ones as input/ouput pins. As default (POR, BOR or any other reset), ANSEL has "1" in all its bits, so, all of them are defined as analog ports. I guess you have to check mcc instructions, and verify that ANSEL definitions are explicitly followed. Anyway, if you got it through that shadow var, and don´t mess with memory capacity, well, fine! Happy new year!!!! Regards,
|
|
|
Logged
|
You can't have your cake and eat it too... except if you do.
|
|
|
|