interfacing MC9S08DZ60 to Hall sensors

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

interfacing MC9S08DZ60 to Hall sensors

1,904 Views
EtherJones
Contributor II
Hello,
 
What's the best way to interface the MC9S08DZ60 to Hall sensors (to commutate a brushless DC motor) ?
 
I need to detect the change in the Hall sensor output in both directions, so I need to detect (and interrupt on) both rising and falling edges.
 
As I read the data sheet, GPIO pins can be configured to detect either rising or falling, but not both.
 
Is it OK to tie 2 GPIO pins together, and configure one for rising and the other for falling?  That would generate 2 separate interrupts for each Hall sensor, but that's OK - I could just set a flag to indicate which interrupt is being serviced and call a common routine.
 
Is there a better way to do this that I am missing? 
 
I thought about using a TPM channel as input capture (since that can be configured to interrupt on both edges) but all the TPM channels are being used.
 
Thank you.
Labels (1)
0 Kudos
Reply
2 Replies

692 Views
rocco
Senior Contributor II
Hi, Ether:

It's too bad that you have no input-captures available, because they are perfect for this. I use them to interrupt on each hall-sensor edge, and then use the captured time values to calculate velocity and acceleration in order to close the velocity loop.

But as Peg suggested, you can use one input pin per hall, and toggle the edge sensitivity after each interrupt. You could then read the timer within the ISR to extract velocity info, without much loss of accuracy.
0 Kudos
Reply

692 Views
peg
Senior Contributor IV
Hi,
This is going to be a busy little micro!
It's no problem to tie two inputs together to achieve this.
Or maybe flip the edge detection after each edge?
Seems like we have been here before
 
Regards
Peg
 
0 Kudos
Reply