I have pickit3. I can program the IC by myself. Thanks.
- - - Updated - - -
The circuit is not complex. I will send the complete circuit now.
I can burn HEX onto Chips. I use MPLAB, PICAKIT3
- - - Updated - - -
View attachment 146479
This is what the MCU will control. It will switch off the relay driver during high voltage.
Thanks.
That's OK. Processor has 1k words, hex address counts bytes. CCS C would never compile the code if it doesn't fit the processor flash.Further, the device as 1K words for the program and you are using floating point calculations. The HEX file shows addresses up to 0x4d5 but the program address space on that chip only goes to 0x3ff so I doubt if it will fit.
The flag variables are reset in the main code. They should be declared volatile, but CCS C never optimizes code in a way that volatile takes effect. Porting the code to other compilers may require it, depending on the optimization settings. Bit flags can be declared as int1 in CCS C to save code and data space, by the way.However there are variables with names such as 'delay_3sec', 'delay_5sec' that are set to false as part of the initialisation, then set to true in the ISR and tested in the main loop. For a start, such variables should be declared as 'volatile' so the compiler will force a read of the variable outside the main loop. However the real problem is that these variables are never set to false.
I have not tried the code but I'm a bit skeptical about a few aspects of it.
Firstly, there are only 64 bytes of data memory and you use 42 of them in the main C file. Are any used in the library functions that are called?
Further, the device as 1K words for the program and you are using floating point calculations. The HEX file shows addresses up to 0x4d5 but the program address space on that chip only goes to 0x3ff so I doubt if it will fit.
I see references to RTCC- the target device does not have an RTCC and the OP has not included one is the design. Going by the CCS User Manual, this uses 'Timer0' which is an 8-bit timer. However you initialise the count to 'HIGH_START' which is defined to be "0xFFFF - 500" - i.e. a 16 bit value.
You have effectively written a state machine to handle when the LEDs are to turn on and off - this is a very reasonable way to go about this task. However there are variables with names such as 'delay_3sec', 'delay_5sec' that are set to false as part of the initialisation, then set to true in the ISR and tested in the main loop. FOr a start, such variables should be declared as 'volatile' so the compiler will force a read of the variable outside the main loop. However the real problem is that these variables are never set to false.
I'm only too happy to be proved wrong, but I don't think you are really helping the OP. It is far better for them to learn how to program the device themselves than to be given (in my opinion) poorly written code to use as an example that must be significantly re-written to make fit in the MCU, let alone made to work.
Susan
"I planned to ask these questions today.
for example:
"if AN0 is 1V or above --- AN2 becomes High with Delay 10 Seconds"
does AN0 have to stay above 1V during these 10 Seconds?
Well Klaus, I think you just got nominated to be a UNICEF ambassador :-DPlease Moderator Klaus, you are like our father here... Please help your Children
I have modified and tested the program.
I have added a TestPin.
Pin 4 (GP3 / MCLR) must be connected with 10k to + (VDD) becomes TestPin.
Normal operation TestPin open Led flicker with cadence of 1 sec.
When TestPin is connected to GND, Led will flash quickly, the delay will be practically disabled. u You can test the level with the potentiometers.
ROM used: 738 words (72%)
Largest free fragment is 286
RAM used: 36 (56%) at main() level
53 (83%) worst case
Stack: 3 worst case (2 in main + 1 for interrupts)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?