Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | Reg problem with Input capture interrupts

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

Reg problem with Input capture interrupts - saravanan - Feb 11 12:28:14 2008


Dear all,

I am using HCS12X evaluation board.I wrote a simple code to
compute the wheel speed using the input capture timer. I have connected
the wheel speed outputs to the channels IOC0 - IOC3. Now the wheels are
moving at a constant pace.

The problem what I am facing is, as TIE(C0I) has higher
priority than the remaining three(C1I,C2I,C3I), channel 0 interrupt
continuosly occurs and doesn't allow the other interrupts to occur.

So can any one help me with this please.
Thanks & Regards,
Sara



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: Reg problem with Input capture interrupts - Edward Karpicz - Feb 11 12:57:37 2008

"saravanan" wrote:

>
> Dear all,
>
> I am using HCS12X evaluation board.I wrote a simple code to
> compute the wheel speed using the input capture timer. I have connected
> the wheel speed outputs to the channels IOC0 - IOC3. Now the wheels are
> moving at a constant pace.
>
> The problem what I am facing is, as TIE(C0I) has higher
> priority than the remaining three(C1I,C2I,C3I), channel 0 interrupt
> continuosly occurs and doesn't allow the other interrupts to occur.
>

Are you clearing interrupt flags properly? I hope you aren't doing it
something like this: TFLG1_C0F=1. It's obvious that TFLG1_C0F=1 can write
more ones to TFLG1 register than just to C0F. So it clears more TFLG1 flags
and you are loosing interrupts.

Edward
> So can any one help me with this please.
> Thanks & Regards,
> Sara
>



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Reg problem with Input capture interrupts - saravanan - Feb 11 22:47:35 2008

--- In 6...@yahoogroups.com, "Edward Karpicz" wrote:
Hi Edward & all,

No I'm clearing the flags at the beginning of the interrupt
itself. But still as all these are occuring at the same time CPU
gives priority to the Channel 0.
I have attached that portion of the code below. So wat can be the
solution for this.

interrupt void inputcapture1(void)
{
TFLG1_C0F = 1; // clear flag
PORTB_PB0 ^=1; // just for my reference
if ((edgecount1 ==0) && (timeof1stedgecounter1 ==0))
timeof1stedgecounter1 = TC0;

timeoflastedgecounter1 = TC0;

edgecount1 ++;

}



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Reg problem with Input capture interrupts - saravanan - Feb 11 23:07:38 2008

--- In 6...@yahoogroups.com, "Cady, Fred" wrote:

Hi Fred,
Thanks a lot. That has solved the problem.
Thank you friends for your help.

Regards,
Sara
>
> Hi,
> It looks to me like the problem is that your TFLG1_C0F = 1;
statement
> compiles to a bset _TFLG1,#1 instruction which won't work to reset
flags
> in the HC(S)12.
> The way the bset instruction works is that the register is first
read by
> the CPU, then the bit you want set is ORed and then the byte is
written
> back to the register. If any of the other flags are set they well be
> reset.
>
> The way to do it is to make sure your compiler generates a store
> instruction.
> Try this:
> TFLG1 = TFLG1_C0F_MASK;
>
> Here is how CodeWarrior compiles these instruction:
> 10: TFLG1_C0F = 1;
> 0002 4c0001 [4] BSET _TFLG1,#1
> 11: TFLG1 = TFLG1_C0F_MASK;
> 0005 c601 [1] LDAB #1
> 0007 5b00 [2] STAB _TFLG1
>
>
> Cheers,
>
>
>
> Fred Cady
> fcady@...
>
>
> ________________________________
>
> From: 6...@yahoogroups.com [mailto:6...@yahoogroups.com]
On
> Behalf Of saravanan
> Sent: Monday, February 11, 2008 8:39 PM
> To: 6...@yahoogroups.com
> Subject: [68HC12] Re: Reg problem with Input capture
interrupts
>
>
>
> --- In 6...@yahoogroups.com 40yahoogroups.com>
> , "Edward Karpicz" wrote:
>
> Hi Edward & all,
>
> No I'm clearing the flags at the beginning of the interrupt
> itself. But still as all these are occuring at the same time
CPU
>
> gives priority to the Channel 0.
> I have attached that portion of the code below. So wat can be
> the
> solution for this.
>
> interrupt void inputcapture1(void)
> {
> TFLG1_C0F = 1; // clear flag
> PORTB_PB0 ^=1; // just for my reference
>
> if ((edgecount1 ==0) && (timeof1stedgecounter1 ==0))
> timeof1stedgecounter1 = TC0;
>
> timeoflastedgecounter1 = TC0;
>
> edgecount1 ++;
>
> }
>
>
>
>
>
> This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager. This message contains confidential information
and is intended only for the individual named. If you are not the
named addressee you should not disseminate, distribute or copy this e-
mail.
> [Non-text portions of this message have been removed]
>



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

RE: Re: Reg problem with Input capture interrupts - "Cady, Fred" - Feb 11 23:58:21 2008

Hi,
It looks to me like the problem is that your TFLG1_C0F = 1; statement
compiles to a bset _TFLG1,#1 instruction which won't work to reset flags
in the HC(S)12.
The way the bset instruction works is that the register is first read by
the CPU, then the bit you want set is ORed and then the byte is written
back to the register. If any of the other flags are set they well be
reset.

The way to do it is to make sure your compiler generates a store
instruction.
Try this:
TFLG1 = TFLG1_C0F_MASK;

Here is how CodeWarrior compiles these instruction:
10: TFLG1_C0F = 1;
0002 4c0001 [4] BSET _TFLG1,#1
11: TFLG1 = TFLG1_C0F_MASK;
0005 c601 [1] LDAB #1
0007 5b00 [2] STAB _TFLG1

Cheers,

Fred Cady
f...@ieee.org

________________________________

From: 6...@yahoogroups.com [mailto:6...@yahoogroups.com] On
Behalf Of saravanan
Sent: Monday, February 11, 2008 8:39 PM
To: 6...@yahoogroups.com
Subject: [68HC12] Re: Reg problem with Input capture interrupts

--- In 6...@yahoogroups.com
, "Edward Karpicz" wrote:

Hi Edward & all,

No I'm clearing the flags at the beginning of the interrupt
itself. But still as all these are occuring at the same time CPU

gives priority to the Channel 0.
I have attached that portion of the code below. So wat can be
the
solution for this.

interrupt void inputcapture1(void)
{
TFLG1_C0F = 1; // clear flag
PORTB_PB0 ^=1; // just for my reference

if ((edgecount1 ==0) && (timeof1stedgecounter1 ==0))
timeof1stedgecounter1 = TC0;

timeoflastedgecounter1 = TC0;

edgecount1 ++;

}

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
[Non-text portions of this message have been removed]



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Re: Reg problem with Input capture interrupts - Edward Karpicz - Feb 12 14:01:35 2008

Fred,

I just want to emphasize that BSET instruction isn't guilty. Also compiler
doesn't do anything wrong generating code with BSET. Less optimized compiler
could compile TFLG1_C0F = 1; to something like this:

ldaa TFLG1
oraa #1
staa TFLG1

No single bset, but code is still buggy and clears more flags than expected.
Registers like TFLG1 are not bitfields compatible and clearing flag this way
TFLG1_C0F = 1 - is a bug.

Edward

----- Original Message -----
From: "Cady, Fred"
To: <6...@yahoogroups.com>
Sent: Tuesday, February 12, 2008 5:55 AM
Subject: RE: [68HC12] Re: Reg problem with Input capture interrupts
> Hi,
> It looks to me like the problem is that your TFLG1_C0F = 1; statement
> compiles to a bset _TFLG1,#1 instruction which won't work to reset flags
> in the HC(S)12.
> The way the bset instruction works is that the register is first read by
> the CPU, then the bit you want set is ORed and then the byte is written
> back to the register. If any of the other flags are set they well be
> reset.
>
> The way to do it is to make sure your compiler generates a store
> instruction.
> Try this:
> TFLG1 = TFLG1_C0F_MASK;
>
> Here is how CodeWarrior compiles these instruction:
> 10: TFLG1_C0F = 1;
> 0002 4c0001 [4] BSET _TFLG1,#1
> 11: TFLG1 = TFLG1_C0F_MASK;
> 0005 c601 [1] LDAB #1
> 0007 5b00 [2] STAB _TFLG1
> Cheers,
>
> Fred Cady
> f...@ieee.org
> ________________________________
>
> From: 6...@yahoogroups.com [mailto:6...@yahoogroups.com] On
> Behalf Of saravanan
> Sent: Monday, February 11, 2008 8:39 PM
> To: 6...@yahoogroups.com
> Subject: [68HC12] Re: Reg problem with Input capture interrupts
>
> --- In 6...@yahoogroups.com
> , "Edward Karpicz" wrote:
>
> Hi Edward & all,
>
> No I'm clearing the flags at the beginning of the interrupt
> itself. But still as all these are occuring at the same time CPU
>
> gives priority to the Channel 0.
> I have attached that portion of the code below. So wat can be
> the
> solution for this.
>
> interrupt void inputcapture1(void)
> {
> TFLG1_C0F = 1; // clear flag
> PORTB_PB0 ^=1; // just for my reference
>
> if ((edgecount1 ==0) && (timeof1stedgecounter1 ==0))
> timeof1stedgecounter1 = TC0;
>
> timeoflastedgecounter1 = TC0;
>
> edgecount1 ++;
>
> }
>
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you have received this email in error please notify the system manager.
> This message contains confidential information and is intended only for
> the individual named. If you are not the named addressee you should not
> disseminate, distribute or copy this e-mail.
> [Non-text portions of this message have been removed]
>



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )