Ubirajara Marques da Cruz
2017-06-05 15:28:10 UTC
Hi all,
IŽve been trying to implement TDC(time delay close) and TDO (time delay open) contact relays into pic program and I am facing some trouble that I need to clarify. I am working with pic 16f877a and SDCC 3.6. IŽm not an assembler programmer only C programmer.
What my program need to do.
It need to charge datas asynchronous event time into an array of timer event structures, sequences it, and order fastest event to slowest and change output relay into right time. I plan to use only one pic timer to do this and I can have until 6 time contact relays.
1st) About struct
I created a typedef struct tmrevent that holds 5 int members to hold TMR1H, TMR1L, overflowtimertimes and another int datas. Into Gcc this array could be done like this:
Typedef struct tmrevent {
int member1;
int member2;
...
int member;
};
tmrevent tv[4];
this code in Gcc works fine and I have an array of tmrevent struct with 4 structs. But in SDCC this code compiles but doesn't link. Why?
Is there another way to define an array of structs in SDCC? Could you tell me pls?
2nd) If I address only one struct my code works but I must declare it like an array like below and only one array element is possible to use. My sdcc installation doesnŽt have MALLOC.H header file to declare a space to hold many struct in a pointer.
__at(0x0020) tmrevent tv[]; // compiles and linker but only one element works
3rd) I read sdcc 3.6.1 manual item 3.1.1 (only this item talk about structures in manual ) but I canŽt clarify much about how structs could be declare with sdcc. Could you inform some book or tutorial that cover this subject. I will appreciate a lot.
4th) I did a test declaring many separate timer event structs addressing directly all of them respecting GPIO addressable memory. I try to use more than a memory bank and another problem occurs. It seems bank 1 is mirrored of bank 0. I found some posts that tell about this condition but none explain how to use direct address to write member structs in the correct bank. For example if I declare a struct in address 0x0020 (first gpio in bank 0 ) the code works fine. If I declare this struct into address 0x00A0 (first gpio in bank 1) sometimes the code works sometimes donŽt. What could be? It seems when program counter is on bank 1 or bank 2 or 3 and interrupt overflow time occurs data that will be record in bank 0 isnŽt correctly write. But in SDCC I didnŽt find any example to solve this doubt.
I will appreciate a lot some answer.
Thank you all
Ubirajara Marques da Cruz
Email: ***@cemig.com.br<mailto:***@cemig.com.br>
As informações contidas nesta mensagem e nos arquivos anexados são para uso exclusivo do destinatário aqui indicado e podem conter assuntos comerciais, de propriedade intelectual ou outras informações confidenciais, protegidas pelas leis aplicáveis. É expressamente proibido o uso não autorizado ou a disseminação desta mensagem ou parte dela. Caso não seja o destinatário correto, por favor, notifique o remetente.
IŽve been trying to implement TDC(time delay close) and TDO (time delay open) contact relays into pic program and I am facing some trouble that I need to clarify. I am working with pic 16f877a and SDCC 3.6. IŽm not an assembler programmer only C programmer.
What my program need to do.
It need to charge datas asynchronous event time into an array of timer event structures, sequences it, and order fastest event to slowest and change output relay into right time. I plan to use only one pic timer to do this and I can have until 6 time contact relays.
1st) About struct
I created a typedef struct tmrevent that holds 5 int members to hold TMR1H, TMR1L, overflowtimertimes and another int datas. Into Gcc this array could be done like this:
Typedef struct tmrevent {
int member1;
int member2;
...
int member;
};
tmrevent tv[4];
this code in Gcc works fine and I have an array of tmrevent struct with 4 structs. But in SDCC this code compiles but doesn't link. Why?
Is there another way to define an array of structs in SDCC? Could you tell me pls?
2nd) If I address only one struct my code works but I must declare it like an array like below and only one array element is possible to use. My sdcc installation doesnŽt have MALLOC.H header file to declare a space to hold many struct in a pointer.
__at(0x0020) tmrevent tv[]; // compiles and linker but only one element works
3rd) I read sdcc 3.6.1 manual item 3.1.1 (only this item talk about structures in manual ) but I canŽt clarify much about how structs could be declare with sdcc. Could you inform some book or tutorial that cover this subject. I will appreciate a lot.
4th) I did a test declaring many separate timer event structs addressing directly all of them respecting GPIO addressable memory. I try to use more than a memory bank and another problem occurs. It seems bank 1 is mirrored of bank 0. I found some posts that tell about this condition but none explain how to use direct address to write member structs in the correct bank. For example if I declare a struct in address 0x0020 (first gpio in bank 0 ) the code works fine. If I declare this struct into address 0x00A0 (first gpio in bank 1) sometimes the code works sometimes donŽt. What could be? It seems when program counter is on bank 1 or bank 2 or 3 and interrupt overflow time occurs data that will be record in bank 0 isnŽt correctly write. But in SDCC I didnŽt find any example to solve this doubt.
I will appreciate a lot some answer.
Thank you all
Ubirajara Marques da Cruz
Email: ***@cemig.com.br<mailto:***@cemig.com.br>
As informações contidas nesta mensagem e nos arquivos anexados são para uso exclusivo do destinatário aqui indicado e podem conter assuntos comerciais, de propriedade intelectual ou outras informações confidenciais, protegidas pelas leis aplicáveis. É expressamente proibido o uso não autorizado ou a disseminação desta mensagem ou parte dela. Caso não seja o destinatário correto, por favor, notifique o remetente.