Add C code to HI-TECH C v9.70 for PIC12F629 (by maxxir)
Hello, Jonathan!
Sorry for my bad English.
I tried to port a little project LDMicro
in applications written in on HI-TECH C v9.70 Lite for PIC12F629.
The application works!
But I can not get run macros, like:
# define Read_U_b_XDVIG (GPIO2)
I have to I / O is implemented through the function, like:
BOOL Read_U_b_XDVIG (void)
{
return GPIO2;
}
That ugly and rather slow.
Unfortunately inline directive is not allowed in this compiler
How did get macros to work in the program?
I hope for your help
The source program and the circuit attached
(no subject) (by Jonathan Westhues)
The correct macro would be something like
#define Read_U_b_XDVIG() (GPIO2)
You need the extra parentheses, since that's how the generated code calls it. You should also #define NO_PROTOTYPES somewhere in ladder.h, since the generated code will otherwise contain prototypes for the functions, as if they were functions and not macros. With those changes, I would guess that your program will work.
(no subject) (by maxxir)
I've done all the recommended steps
but nevertheless, the program will not compile.
Compiler messages now:
Warning [361] H:\microchip_pic12\pic12_ladder_bathroom_light\vanna.c; 97.4 function declared implicit int
Warning [361] H:\microchip_pic12\pic12_ladder_bathroom_light\vanna.c; 104.4 function declared implicit int
Warning [361] H:\microchip_pic12\pic12_ladder_bathroom_light\vanna.c; 171.1 function declared implicit int
Error [500] ; 0. undefined symbols:
_Read_U_b_XDVIG(ladder.obj) _Read_U_b_XDOOR(ladder.obj) _Write_U_b_Yout(ladder.obj)
********** Build failed! **********
It seems that the compiler does not see
#define Read_U_b_XDVIG() (GPIO2)
Although I have added code
#define NO_PROTOTYPES in ladder.h
(no subject) (by Jonathan Westhues)
The macro has to be defined somewhere that it's visible inside the generated C code vanna.c, for example in ladder.h.
(no subject) (by maxxir)
Thank you Jonathan!
Now the code to work properly.
ladder.h looks in the final version as follows:
/* Type definitions for HTC PICC*/
#ifndef _HTC_H_
#include <htc.h>
#endif
#define BOOL unsigned char
#define SWORD signed int
#define NO_PROTOTYPES
//--- All inputs and outputs from ladder diagramm to real MCU definitions here
#define Read_U_b_XDVIG() (GPIO2)
#define Read_U_b_XDOOR() (GPIO5)
#define Write_U_b_Yout(v) {\
if((v))\
GPIO4 = 1;\
else\
GPIO4 = 0;}
I attach the final version of the source and the schema
maybe someone will prove useful.
Best regards Ibragimov Maxim