Thanks Henrik,
I read the data sheet... but , to be sure : have you some sample to help in setting the register please ?
I really need three input and three output pins.
Thanks again
regards,
Ambrogio
Thanks Henrik,
I read the data sheet... but , to be sure : have you some sample to help in setting the register please ?
I really need three input and three output pins.
Thanks again
regards,
Ambrogio
Could you please indicate tio me the correct syntax for the DEBUG ?
( I do not understand how to write the debug in case GPIO is involved ).
more properly would be
DEFINE DEBUG_REG GPIO
but it seems not to matter in this instance ,would also be wise to set the pin as digital too I think
Warning I'm not a teacher
The datasheet says: The ANSEL (9Fh) and CMCON (19h) registers (9Fh) must be initialized to configure an analog channel as a digital input.I read the data sheet... but , to be sure : have you some sample to help in setting the register please ?
So lets start with ANSEL (page 44 in the datasheet)where the lower four bits determines if AN0-AN3 should be analog (which they are by default) or digital. These bits needs to zero for the pins to be digital and since you're not using the ADC the state of the other bits doesn't matter, therefor ANSEL = 0 will do just fine.
Next. CMCON, figure 6-2 (page 37) in the datasheet shows the various configurations, you don't want to use the comparator so it should be off, therefor CMCON = 7
Finally you say that you need three inputs and three outputs but not which pins should be what so I can't tell you more than that you need to set TRISIO up with a '1' for each input and a '0' for each output. Remember that the MCLR-pin (GP3) can not be configured as an output.
/Henrik.Code:ANSEL = 0 CMCON = 7 TRISIO = %00111000 ' GP0-GP2 outputs, GP3-GP5 inputs.
Last edited by HenrikOlsson; - 9th May 2017 at 10:10.
Thanks,
I corrected the define debug as indicated and it OK too.
I do not understand the data sheet as far as the GPIO setting is concerned:
bit 5-0: GPIO<5:0>: General Purpose I/O pin.
1 = Port pin is >VIH
0 = Port pin is <VIL
I have to read both states of the pin.
Could you please clarify ?
Thanks
regards,
Ambrogio
thanks Henrik,
I received your msg 7 just now. Now it is very clear to me ,.
In my previous msg I refer to register 05h.
rgds,
Ambro
I wouldn't call the GPIO registers a "setting" (though it's really no different than any other register). It is the port register which is connected to the actual I/O pins.
Write to GPIO and the bits will appear on the port pins configured as outputs. Read from GPIO and you'll get the state of the register. The state of each individual bit will properly reflect the state logic state of the actual pin provided that the pin IS set to digital, it IS set to input and the voltage is either less than VIL (for a logic zero) or more than VIH (for a logic one).
In other words, if the voltage on GPIO.0 is less than VIL myVAR = GPIO.0 will be 0 and if the voltage is higher than VIH myVAR = GPIO.0 will be 1. If the voltage is somewhere in between VIL and VIH the result is unspecified.
Your original problem was that the pin was not set to digital and as the datasheet says: I/O pins configured as analog inputs always read ‘0’.
/Henrik.
Hi,
it is working for the first time. If I do reprogram the chip then I have the following message:
017-05-09 12:13:19 +0200 - Programming...
Target has invalid calibration data (0x00).
Device Erased...
Programming...
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x45
configuration memory
program memory
Address: 0 Expected Value: 2828 Received Value: 0
Failed to program device
2017-05-09 12:13:23 +0200 - Programming failed
Pass Count: 49
It is the first time I face with a so small PIC devices... Is it critical ?
thanks
Ambro
Not sure but I believe it might have something to do with the calibration value for the internal oscillator. I see you're manually setting OSCCAL to 64 at the top of the program but I'm wondering if what the error message is trying to say is that you've erased the factory calibration value originally stored in the PIC. Does the program work at all?
If you want PBP to use the default calibration value add DEFINE OSCCAL_1K 1 but it will obviously not work on a device where you've erased the calibration value.
yes, the program that I loaded before still runs.
No other code can be loaded .
I changed the micro : all OK at first programming. The same message comes out at the second programming.
regards,
Thanks
Ambro
Bookmarks