Freeing IOs

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

 Hi,

   

I'm new to PSoC world, trying to improve m'y customer PSoC1 CY8C29466 design.

   

The current dev is using a  zero cross detection done with a comparator which triggers a GPIO interrupt on every half cycle (Change From Read) of the 292Hz input sinusoidal signal.

   

Such a routing is consumming one GPIO pin only for the purpose of linking the output of the comparator to tne input of the interrupt pin driver thru the out analog bus of the concerned column.

   

Would there be another way to generate the interrupt without using the corresponding  pin as analog outputs are rare ressource? 

   

Regards, 

   

Michel

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Hi Michel,

   

each of the 4 comparators provide a sole interrupt, have a look into the datasheet of your COMP-module. You have to use an API to enable the interrupt and then you do not need any pin.

   

Are you familar with the (a bit complex) way to tell your PSoC to execute your interrupt-code?

   

 

   

Bob

0 Likes
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hi Bob,

   

This is really good news, gonna check this immediately, thanks for the information.

   

The PSoC familly is very rich in terms of ressouces, so a lot to read before being proficient, this requires time...

   

I'm familiar with interrupt sequences on other microcontroller brands, have already analysed how the PSoC1 Interrupt Controller works and how to manage the handler(s) so I don't think I'd be stuck on insoluble problems on this side.

   

But if needed, will ask for.

   

Best regards,

   

Michel

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

So as I see you are not yet experienced in writing interrupt routines for PSoC1, it is (as I said) a bit complicated.

   

Interrupt routines should be kept small to have a small latency, but for now I would prefer every simple but working solution.

   

First

   

#pragma interrupt_handler MyIntRoutine

   

 

   

void MyIntRoutine(void)

   

{

   

    // All registers used in this routine are saved on the stack by the compiler

   

    // Do NOT call delay-functions, don't wait for anything, no LCD-output

   

    // Simplest is to set a flag and test for it in the main-loop

   

    // When calling a function() within this interrupt-routine the compiler will generate additional code

   

        // to save ALL REGISTERS on the stack at entry of the interrupt routine (~ 22 bytes)

   

}

   

 

   

second

   

Edit the file "Boot.tpl" (you'll have to search for it in the pjoject folder). This file is a template (thus the .tpl) from which the "Boot.asm" is generated. The jump-table and its entries are clearly marked. insert at the appropiate plae a

   

LJMP _MyIntRoutine    ; The unserscore (_) is needed!!!

   

 

   

Happy coding

   

Bob

0 Likes
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

 Well, I understand now why it was built with an IO.

   

In fact the current design is using the legacy CMPPRG module which has no interrup capability.

   

So I need to shift to the updated COMPZ and trigger its interrupt.

   

Thx again for your answer, it helped.

   

Michel 

0 Likes
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Bob,

   

My last post went before I read your advices.

   

I already know all this, I studied the customer code and many examples which are given thru the PSoC related web sites.

   

But this is a good review of how it works, again thanks for this valuable information.

   

Regards,

   

Michel

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Might be, you misunderstood: You will have connect your comparator to the Comp-Bus. Then you may use the interrupt of the comp-bus

   

 

   

Bob

0 Likes
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

 OK Bob,

   

I'm lucky the output is already attached to the comp bus as I'm also using it to switch the sign of the rectifier module.

   

 Thx.

   

Michel

0 Likes