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 | a problem with reading continuous values into Microcontroller

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

a problem with reading continuous values into Microcontroller - roopa valluri - Sep 6 20:37:30 2008

hello can any body help me with a problem of reading continuous voltages into the controller comparing the voltages read and generating pulses as per the logic listed in the program.
the code should basically read the voltages continuously and compare the voltages and generate pulses at PWM port. But my code is not reading the voltages as and when they are changed it has to be compiled for the new values to reflect but I believe I have written the code to read the values continuously. Please somebody go through my code and please help me solve this issue.

.nolist
#include hc12.inc
;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
.list
;RAM_START equ $0800
org RAM_START

; ----------------------------------------------------------------------
; MAIN PROGRAM
; ----------------------------------------------------------------------

BSR INIT ; Branch to INIT subroutine to Initialize ATD
BSR CONVERT ; Branch to CONVERT Subroutine for conversion
DONE: BRA DONE ; Branch to Self, Convenient place for breakpoint

; ----------------------------------------------
; Subroutine INIT: Initialize ATD ;
; ----------------------------------------------

INIT:
LDAA #$80 ; Allow ATD to function normally,
STAA ATDCTL2 ; ATD Flags clear normally & disable interrupts

BSR DELAY ; Delay (100 uS) for WAIT delay time.

LDAA #$00 ; Select continue conversion in BGND Mode
STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3

LDAA #$02 ; Select Final Sample time = 2 A/D clocks
STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)

RTS ; Return from subroutine

CONVERT:LDAA #%00010110
STAA ATDCTL5
WTCONV: BRCLR ATDSTATH,#$80,WTCONV ; Wait for Sequence Complete Flag
LDAA ADR2H ; Loads conversion result(ADR2H) into Accumulator
LDAB ADR3H
swi
movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
movb #$01,PWPOL ;source is clk A
clr PWCTL
clr PWTST
movb #%00000011,PWEN ;enable PWEN0/1
CBA
;swi
BMI PWM1
BPL PWM2
jsr delay_1
jmp CONVERT
RTS ; Return from subroutine

;* -------------------------------
;* Subroutine DELAY 100 uS *
;* -------------------------------
; Delay Required for ATD converter to Stabilize (100 uSec)

LDAA #$C8 ; Load Accumulator with "100 uSec delay value"
DELAY: DECA ; Decrement ACC
BNE DELAY ; Branch if not equal to Zero
RTS ; Return from subroutine
PWM1:
movw #$0005,PWPER0 ;period
movw #$0003,PWDTY0 ;duty

RTS
;end of pwm1
PWM2:
movw #$0005,PWPER0 ;period
movw #$0001,PWDTY0 ;duty

RTS
; end of pwm

delay_1:pshx
movb #$90,TSCR
movb #$03,TMSK2
movb #$01,TIOS
ldx #20
ldd TCNTH
again: addd #50000
std TC0H
brclr TFLG1,$01,*
ldd TC0H
dbne x,again
pulx
rts
swi
END ; End of program

thank you.
P.S. please help me with this issue asap.

Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

[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 )


Testing for BDM POD connection? - "James M. Knox" - Sep 8 13:20:43 2008


I swear I've seen this answer before, but checking my archives came up dry.

What is the recommended way to tell if the BDM pod is connected to
the HCS12? It would look like DBGEN or BDMACT *might* be relevant,
but neither seem quite right. Because the P&E Micro won't work at
higher MCU frequencies, I need to make the software select a lower
PLL multiplier if the pod is connected.

Suggestions?

-----------------------------------------------
James M. Knox
TriSoft ph 512-385-0316
1300 Koenig Lane West fax 512-371-5716
Suite 200
Austin, Tx 78756 j...@trisoft.com
-----------------------------------------------
------------------------------------



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

Re: a problem with reading continuous values into Microcontroller - Edward Karpicz - Sep 23 0:06:49 2008

Also this looks like a single conversion per reset:

BSR CONVERT ; Branch to CONVERT Subroutine for conversion
DONE: BRA DONE ; Branch to Self, Convenient place for
breakpoint

Edward
----- Original Message -----
From: "Darren Moore"
To: <6...@yahoogroups.com>
Sent: Tuesday, September 23, 2008 2:52 AM
Subject: RE: [68HC12] a problem with reading continuous values into
Microcontroller
> Hi,
>
> The first item I noticed is the Delay 'label' is after the
> ldaa #$c8 instruction, so A is not loaded.
>
> Regards,
> Darren
> -----Original Message-----
> From: 6...@yahoogroups.com [mailto:6...@yahoogroups.com] On Behalf Of
> roopa valluri
> Sent: Tuesday, 23 September 2008 07:32
> To: 6...@yahoogroups.com
> Subject: [68HC12] a problem with reading continuous values into
> Microcontroller
>
> hello can any body help me with a problem of reading continuous voltages
> into the controller comparing the voltages read and generating pulses as
> per
> the logic listed in the program.
> the code should basically read the voltages continuously and compare the
> voltages and generate pulses at PWM port. But my code is not reading the
> voltages as and when they are changed it has to be compiled for the new
> values to reflect but I believe I have written the code to read the values
> continuously. Please somebody go through my code and please help me solve
> this issue.
>
> .nolist
> #include hc12.inc
> ;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
> .list
> ;RAM_START equ $0800
> org RAM_START
>
> ; ----------------------------------------------------------------------
> ; MAIN PROGRAM
> ; ----------------------------------------------------------------------
>
> BSR INIT ; Branch to INIT subroutine to Initialize
> ATD
> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> DONE: BRA DONE ; Branch to Self, Convenient place for
> breakpoint
>
> ; ----------------------------------------------
> ; Subroutine INIT: Initialize ATD ;
> ; ----------------------------------------------
>
> INIT:
> LDAA #$80 ; Allow ATD to function normally,
> STAA ATDCTL2 ; ATD Flags clear normally & disable
> interrupts
>
> BSR DELAY ; Delay (100 uS) for WAIT delay time.
>
> LDAA #$00 ; Select continue conversion in BGND Mode
> STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3
>
> LDAA #$02 ; Select Final Sample time = 2 A/D clocks
> STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)
>
> RTS ; Return from subroutine
>
> CONVERT:LDAA #%00010110
>
> STAA ATDCTL5
>
> WTCONV: BRCLR ATDSTATH,#$80,WTCONV ; Wait for Sequence Complete Flag
> LDAA ADR2H ; Loads conversion result(ADR2H) into
> Accumulator
> LDAB ADR3H
> swi
> movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
> movb #$01,PWPOL ;source is clk A
> clr PWCTL
> clr PWTST
> movb #%00000011,PWEN ;enable PWEN0/1
> CBA
> ;swi
> BMI PWM1
> BPL PWM2
> jsr delay_1
> jmp CONVERT
> RTS ; Return from subroutine
>
> ;* -------------------------------
> ;* Subroutine DELAY 100 uS *
> ;* -------------------------------
> ; Delay Required for ATD converter to Stabilize (100 uSec)
>
> LDAA #$C8 ; Load Accumulator with "100 uSec delay
> value"
> DELAY: DECA ; Decrement ACC
> BNE DELAY ; Branch if not equal to Zero
> RTS ; Return from subroutine
> PWM1:
> movw #$0005,PWPER0 ;period
> movw #$0003,PWDTY0 ;duty
>
> RTS
> ;end of pwm1
> PWM2:
> movw #$0005,PWPER0 ;period
> movw #$0001,PWDTY0 ;duty
>
> RTS
> ; end of pwm
>
> delay_1:pshx
> movb #$90,TSCR
> movb #$03,TMSK2
> movb #$01,TIOS
> ldx #20
> ldd TCNTH
> again: addd #50000
> std TC0H
> brclr TFLG1,$01,*
> ldd TC0H
> dbne x,again
> pulx
> rts
> swi
> END ; End of program
>
> thank you.
> P.S. please help me with this issue asap.
>
> ________________________________
> Unlimited freedom, unlimited storage. Get it now
> Add more friends to your messenger and enjoy! Go to
> http://in.messenger.yahoo.com/invite/
>
> [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: a problem with reading continuous values into Microcontroller - roopa valluri - Sep 23 20:23:47 2008

Hello Edward,
if i need to make this a continuous conversion what needs to be done ..I am unable to figure it out. I also tried making it to scan continuously but havent found any difference. So if it has to continuously do the conversion what changes do you suggest.

thanks,
roopa

----- Original Message ----
From: Edward Karpicz
To: 6...@yahoogroups.com
Sent: Tuesday, 23 September, 2008 12:06:28 AM
Subject: Re: [68HC12] a problem with reading continuous values into Microcontroller
Also this looks like a single conversion per reset:

BSR CONVERT ; Branch to CONVERT Subroutine for conversion
DONE: BRA DONE ; Branch to Self, Convenient place for
breakpoint

Edward

----- Original Message -----
From: "Darren Moore"
To: <68HC12@yahoogroups. com>
Sent: Tuesday, September 23, 2008 2:52 AM
Subject: RE: [68HC12] a problem with reading continuous values into
Microcontroller

> Hi,
>
> The first item I noticed is the Delay 'label' is after the
> ldaa #$c8 instruction, so A is not loaded.
>
> Regards,
> Darren
> -----Original Message-----
> From: 68HC12@yahoogroups. com [mailto:68HC12@yahoogroups. com] On Behalf Of
> roopa valluri
> Sent: Tuesday, 23 September 2008 07:32
> To: 68HC12@yahoogroups. com
> Subject: [68HC12] a problem with reading continuous values into
> Microcontroller
>
> hello can any body help me with a problem of reading continuous voltages
> into the controller comparing the voltages read and generating pulses as
> per
> the logic listed in the program.
> the code should basically read the voltages continuously and compare the
> voltages and generate pulses at PWM port. But my code is not reading the
> voltages as and when they are changed it has to be compiled for the new
> values to reflect but I believe I have written the code to read the values
> continuously. Please somebody go through my code and please help me solve
> this issue.
>
> .nolist
> #include hc12.inc
> ;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
> .list
> ;RAM_START equ $0800
> org RAM_START
>
> ; ------------ --------- --------- --------- --------- --------- -
> ; MAIN PROGRAM
> ; ------------ --------- --------- --------- --------- --------- -
>
> BSR INIT ; Branch to INIT subroutine to Initialize
> ATD
> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> DONE: BRA DONE ; Branch to Self, Convenient place for
> breakpoint
>
> ; ------------ --------- --------- --------- -------
> ; Subroutine INIT: Initialize ATD ;
> ; ------------ --------- --------- --------- -------
>
> INIT:
> LDAA #$80 ; Allow ATD to function normally,
> STAA ATDCTL2 ; ATD Flags clear normally & disable
> interrupts
>
> BSR DELAY ; Delay (100 uS) for WAIT delay time.
>
> LDAA #$00 ; Select continue conversion in BGND Mode
> STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3
>
> LDAA #$02 ; Select Final Sample time = 2 A/D clocks
> STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)
>
> RTS ; Return from subroutine
>
> CONVERT:LDAA #%00010110
>
> STAA ATDCTL5
>
> WTCONV: BRCLR ATDSTATH,#$80, WTCONV ; Wait for Sequence Complete Flag
> LDAA ADR2H ; Loads conversion result(ADR2H) into
> Accumulator
> LDAB ADR3H
> swi
> movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
> movb #$01,PWPOL ;source is clk A
> clr PWCTL
> clr PWTST
> movb #%00000011,PWEN ;enable PWEN0/1
> CBA
> ;swi
> BMI PWM1
> BPL PWM2
> jsr delay_1
> jmp CONVERT
> RTS ; Return from subroutine
>
> ;* ------------ --------- --------- -
> ;* Subroutine DELAY 100 uS *
> ;* ------------ --------- --------- -
> ; Delay Required for ATD converter to Stabilize (100 uSec)
>
> LDAA #$C8 ; Load Accumulator with "100 uSec delay
> value"
> DELAY: DECA ; Decrement ACC
> BNE DELAY ; Branch if not equal to Zero
> RTS ; Return from subroutine
> PWM1:
> movw #$0005,PWPER0 ;period
> movw #$0003,PWDTY0 ;duty
>
> RTS
> ;end of pwm1
> PWM2:
> movw #$0005,PWPER0 ;period
> movw #$0001,PWDTY0 ;duty
>
> RTS
> ; end of pwm
>
> delay_1:pshx
> movb #$90,TSCR
> movb #$03,TMSK2
> movb #$01,TIOS
> ldx #20
> ldd TCNTH
> again: addd #50000
> std TC0H
> brclr TFLG1,$01,*
> ldd TC0H
> dbne x,again
> pulx
> rts
> swi
> END ; End of program
>
> thank you.
> P.S. please help me with this issue asap.
>
> ____________ _________ _________ __
> Unlimited freedom, unlimited storage. Get it now
> Add more friends to your messenger and enjoy! Go to
> http://in.messenger .yahoo.com/ invite/
>
> [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: a problem with reading continuous values into Microcontroller - Edward Karpicz - Sep 24 3:02:29 2008

bsr CONVERT - that's a single call to convert subroutine, right?
done : bra done - that's a forever loop.

So CONVERT routine is called once per reset. If you didn't see that, then I
guess you can't explain also what SWI instructions are doing in your code.

Edward
----- Original Message -----
From: "roopa valluri"
To: <6...@yahoogroups.com>
Sent: Wednesday, September 24, 2008 03:23
Subject: Re: [68HC12] a problem with reading continuous values into
Microcontroller
> Hello Edward,
> if i need to make this a continuous conversion what needs to be done ..I
> am unable to figure it out. I also tried making it to scan continuously
> but havent found any difference. So if it has to continuously do the
> conversion what changes do you suggest.
>
> thanks,
> roopa
>
> ----- Original Message ----
> From: Edward Karpicz
> To: 6...@yahoogroups.com
> Sent: Tuesday, 23 September, 2008 12:06:28 AM
> Subject: Re: [68HC12] a problem with reading continuous values into
> Microcontroller
> Also this looks like a single conversion per reset:
>
> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> DONE: BRA DONE ; Branch to Self, Convenient place for
> breakpoint
>
> Edward
>
> ----- Original Message -----
> From: "Darren Moore"
> To: <68HC12@yahoogroups. com>
> Sent: Tuesday, September 23, 2008 2:52 AM
> Subject: RE: [68HC12] a problem with reading continuous values into
> Microcontroller
>
>> Hi,
>>
>> The first item I noticed is the Delay 'label' is after the
>> ldaa #$c8 instruction, so A is not loaded.
>>
>> Regards,
>> Darren
>> -----Original Message-----
>> From: 68HC12@yahoogroups. com [mailto:68HC12@yahoogroups. com] On Behalf
>> Of
>> roopa valluri
>> Sent: Tuesday, 23 September 2008 07:32
>> To: 68HC12@yahoogroups. com
>> Subject: [68HC12] a problem with reading continuous values into
>> Microcontroller
>>
>> hello can any body help me with a problem of reading continuous voltages
>> into the controller comparing the voltages read and generating pulses as
>> per
>> the logic listed in the program.
>> the code should basically read the voltages continuously and compare the
>> voltages and generate pulses at PWM port. But my code is not reading the
>> voltages as and when they are changed it has to be compiled for the new
>> values to reflect but I believe I have written the code to read the
>> values
>> continuously. Please somebody go through my code and please help me solve
>> this issue.
>>
>> .nolist
>> #include hc12.inc
>> ;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
>> .list
>> ;RAM_START equ $0800
>> org RAM_START
>>
>> ; ------------ --------- --------- --------- --------- --------- -
>> ; MAIN PROGRAM
>> ; ------------ --------- --------- --------- --------- --------- -
>>
>> BSR INIT ; Branch to INIT subroutine to Initialize
>> ATD
>> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
>> DONE: BRA DONE ; Branch to Self, Convenient place for
>> breakpoint
>>
>> ; ------------ --------- --------- --------- -------
>> ; Subroutine INIT: Initialize ATD ;
>> ; ------------ --------- --------- --------- -------
>>
>> INIT:
>> LDAA #$80 ; Allow ATD to function normally,
>> STAA ATDCTL2 ; ATD Flags clear normally & disable
>> interrupts
>>
>> BSR DELAY ; Delay (100 uS) for WAIT delay time.
>>
>> LDAA #$00 ; Select continue conversion in BGND Mode
>> STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3
>>
>> LDAA #$02 ; Select Final Sample time = 2 A/D clocks
>> STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)
>>
>> RTS ; Return from subroutine
>>
>> CONVERT:LDAA #%00010110
>>
>> STAA ATDCTL5
>>
>> WTCONV: BRCLR ATDSTATH,#$80, WTCONV ; Wait for Sequence Complete Flag
>> LDAA ADR2H ; Loads conversion result(ADR2H) into
>> Accumulator
>> LDAB ADR3H
>> swi
>> movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
>> movb #$01,PWPOL ;source is clk A
>> clr PWCTL
>> clr PWTST
>> movb #%00000011,PWEN ;enable PWEN0/1
>> CBA
>> ;swi
>> BMI PWM1
>> BPL PWM2
>> jsr delay_1
>> jmp CONVERT
>> RTS ; Return from subroutine
>>
>> ;* ------------ --------- --------- -
>> ;* Subroutine DELAY 100 uS *
>> ;* ------------ --------- --------- -
>> ; Delay Required for ATD converter to Stabilize (100 uSec)
>>
>> LDAA #$C8 ; Load Accumulator with "100 uSec delay
>> value"
>> DELAY: DECA ; Decrement ACC
>> BNE DELAY ; Branch if not equal to Zero
>> RTS ; Return from subroutine
>> PWM1:
>> movw #$0005,PWPER0 ;period
>> movw #$0003,PWDTY0 ;duty
>>
>> RTS
>> ;end of pwm1
>> PWM2:
>> movw #$0005,PWPER0 ;period
>> movw #$0001,PWDTY0 ;duty
>>
>> RTS
>> ; end of pwm
>>
>> delay_1:pshx
>> movb #$90,TSCR
>> movb #$03,TMSK2
>> movb #$01,TIOS
>> ldx #20
>> ldd TCNTH
>> again: addd #50000
>> std TC0H
>> brclr TFLG1,$01,*
>> ldd TC0H
>> dbne x,again
>> pulx
>> rts
>> swi
>> END ; End of program
>>
>> thank you.
>> P.S. please help me with this issue asap.
>>
>> ____________ _________ _________ __
>> Unlimited freedom, unlimited storage. Get it now
>> Add more friends to your messenger and enjoy! Go to
>> http://in.messenger .yahoo.com/ invite/
>>
>> [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: a problem with reading continuous values into Microcontroller - "William R. Elliot" - Sep 24 15:05:22 2008

Note that CONVERT is itself an endless loop once it is entered.

At 03:02 AM 9/24/2008, you wrote:
> bsr CONVERT - that's a single call to convert subroutine, right?
> done : bra done - that's a forever loop.
>
>So CONVERT routine is called once per reset. If you didn't see that, then I
>guess you can't explain also what SWI instructions are doing in your code.
>
>Edward
>----- Original Message -----
>From: "roopa valluri"
>To: <6...@yahoogroups.com>
>Sent: Wednesday, September 24, 2008 03:23
>Subject: Re: [68HC12] a problem with reading continuous values into
>Microcontroller
> > Hello Edward,
> > if i need to make this a continuous conversion what needs to be done ..I
> > am unable to figure it out. I also tried making it to scan continuously
> > but havent found any difference. So if it has to continuously do the
> > conversion what changes do you suggest.
> >
> > thanks,
> > roopa
> >
> > ----- Original Message ----
> > From: Edward Karpicz
> > To: 6...@yahoogroups.com
> > Sent: Tuesday, 23 September, 2008 12:06:28 AM
> > Subject: Re: [68HC12] a problem with reading continuous values into
> > Microcontroller
> >
> >
> > Also this looks like a single conversion per reset:
> >
> > BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> > DONE: BRA DONE ; Branch to Self, Convenient place for
> > breakpoint
> >
> > Edward
> >
> > ----- Original Message -----
> > From: "Darren Moore"
> > To: <68HC12@yahoogroups. com>
> > Sent: Tuesday, September 23, 2008 2:52 AM
> > Subject: RE: [68HC12] a problem with reading continuous values into
> > Microcontroller
> >
> >> Hi,
> >>
> >> The first item I noticed is the Delay 'label' is after the
> >> ldaa #$c8 instruction, so A is not loaded.
> >>
> >> Regards,
> >> Darren
> >>
> >>
> >> -----Original Message-----
> >> From: 68HC12@yahoogroups. com [mailto:68HC12@yahoogroups. com] On Behalf
> >> Of
> >> roopa valluri
> >> Sent: Tuesday, 23 September 2008 07:32
> >> To: 68HC12@yahoogroups. com
> >> Subject: [68HC12] a problem with reading continuous values into
> >> Microcontroller
> >>
> >> hello can any body help me with a problem of reading continuous voltages
> >> into the controller comparing the voltages read and generating pulses as
> >> per
> >> the logic listed in the program.
> >> the code should basically read the voltages continuously and compare the
> >> voltages and generate pulses at PWM port. But my code is not reading the
> >> voltages as and when they are changed it has to be compiled for the new
> >> values to reflect but I believe I have written the code to read the
> >> values
> >> continuously. Please somebody go through my code and please help me solve
> >> this issue.
> >>
> >> .nolist
> >> #include hc12.inc
> >> ;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
> >> .list
> >> ;RAM_START equ $0800
> >> org RAM_START
> >>
> >> ; ------------ --------- --------- --------- --------- --------- -
> >> ; MAIN PROGRAM
> >> ; ------------ --------- --------- --------- --------- --------- -
> >>
> >> BSR INIT ; Branch to INIT subroutine to Initialize
> >> ATD
> >> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> >> DONE: BRA DONE ; Branch to Self, Convenient place for
> >> breakpoint
> >>
> >> ; ------------ --------- --------- --------- -------
> >> ; Subroutine INIT: Initialize ATD ;
> >> ; ------------ --------- --------- --------- -------
> >>
> >> INIT:
> >> LDAA #$80 ; Allow ATD to function normally,
> >> STAA ATDCTL2 ; ATD Flags clear normally & disable
> >> interrupts
> >>
> >> BSR DELAY ; Delay (100 uS) for WAIT delay time.
> >>
> >> LDAA #$00 ; Select continue conversion in BGND Mode
> >> STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3
> >>
> >> LDAA #$02 ; Select Final Sample time = 2 A/D clocks
> >> STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)
> >>
> >> RTS ; Return from subroutine
> >>
> >> CONVERT:LDAA #%00010110
> >>
> >> STAA ATDCTL5
> >>
> >> WTCONV: BRCLR ATDSTATH,#$80, WTCONV ; Wait for Sequence Complete Flag
> >> LDAA ADR2H ; Loads conversion result(ADR2H) into
> >> Accumulator
> >> LDAB ADR3H
> >> swi
> >> movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
> >> movb #$01,PWPOL ;source is clk A
> >> clr PWCTL
> >> clr PWTST
> >> movb #%00000011,PWEN ;enable PWEN0/1
> >> CBA
> >> ;swi
> >> BMI PWM1
> >> BPL PWM2
> >> jsr delay_1
> >> jmp CONVERT
> >> RTS ; Return from subroutine
> >>
> >> ;* ------------ --------- --------- -
> >> ;* Subroutine DELAY 100 uS *
> >> ;* ------------ --------- --------- -
> >> ; Delay Required for ATD converter to Stabilize (100 uSec)
> >>
> >> LDAA #$C8 ; Load Accumulator with "100 uSec delay
> >> value"
> >> DELAY: DECA ; Decrement ACC
> >> BNE DELAY ; Branch if not equal to Zero
> >> RTS ; Return from subroutine
> >>
> >>
> >> PWM1:
> >> movw #$0005,PWPER0 ;period
> >> movw #$0003,PWDTY0 ;duty
> >>
> >> RTS
> >> ;end of pwm1
> >> PWM2:
> >> movw #$0005,PWPER0 ;period
> >> movw #$0001,PWDTY0 ;duty
> >>
> >> RTS
> >> ; end of pwm
> >>
> >> delay_1:pshx
> >> movb #$90,TSCR
> >> movb #$03,TMSK2
> >> movb #$01,TIOS
> >> ldx #20
> >> ldd TCNTH
> >> again: addd #50000
> >> std TC0H
> >> brclr TFLG1,$01,*
> >> ldd TC0H
> >> dbne x,again
> >> pulx
> >> rts
> >> swi
> >> END ; End of program
> >>
> >> thank you.
> >> P.S. please help me with this issue asap.
> >>
> >> ____________ _________ _________ __
> >> Unlimited freedom, unlimited storage. Get it now
> >>
> >>
> >> Add more friends to your messenger and enjoy! Go to
> >> http://in.messenger .yahoo.com/ invite/
> >>
> >> [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: a problem with reading continuous values into Microcontroller - roopa valluri - Sep 26 12:22:27 2008

Hello Micheal,
Thanks for the reply.
The requirement with the code is that it should keep on reading voltages from 2 sources and when there is a change in the voltage ( if voltage to one pin is higher than the other or vice-versa) then it should go into the loop PWM1 or PWM2 and do the necessary. But the code once executed should keep on running as opposed to my code which needs constant execution. So can you help me in changing the code as per the requirement.

thanks,
Roopa

----- Original Message ----
From: Michael Burgess
To: 6...@yahoogroups.com
Sent: Wednesday, 24 September, 2008 4:26:32 PM
Subject: Re: [68HC12] a problem with reading continuous values into Microcontroller
*Well, your CONVERT routine has a number of issues. I'm not sure what
your intent really is,
however, it certainly is not an endless loop as you might want. Your
PWM1:, and PWM2:
labels execute to an RTS which will cause a return from the CONVERT
routine. The delay_1
subroutine will never be executed, nor your JMP CONVERT instruction! You
also have the
issues that are mentioned by others on this forum.

Mike B.*

roopa valluri wrote:
>
> hello can any body help me with a problem of reading continuous
> voltages into the controller comparing the voltages read and
> generating pulses as per the logic listed in the program.
> the code should basically read the voltages continuously and compare
> the voltages and generate pulses at PWM port. But my code is not
> reading the voltages as and when they are changed it has to be
> compiled for the new values to reflect but I believe I have written
> the code to read the values continuously. Please somebody go through
> my code and please help me solve this issue.
>
> .nolist
> #include hc12.inc
> ;#INCLUDE 'EQUATES.ASM' ;Equates for all registers
> .list
> ;RAM_START equ $0800
> org RAM_START
>
> ; ----------------------------------------------------------
> ; MAIN PROGRAM
> ; ----------------------------------------------------------
>
> BSR INIT ; Branch to INIT subroutine to Initialize ATD
> BSR CONVERT ; Branch to CONVERT Subroutine for conversion
> DONE: BRA DONE ; Branch to Self, Convenient place for breakpoint
>
> ; ----------------------------------------------
> ; Subroutine INIT: Initialize ATD ;
> ; ----------------------------------------------
>
> INIT:
> LDAA #$80 ; Allow ATD to function normally,
> STAA ATDCTL2 ; ATD Flags clear normally & disable interrupts
>
> BSR DELAY ; Delay (100 uS) for WAIT delay time.
>
> LDAA #$00 ; Select continue conversion in BGND Mode
> STAA ATDCTL3 ; Ignore FREEZE in ATDCTL3
>
> LDAA #$02 ; Select Final Sample time = 2 A/D clocks
> STAA ATDCTL4 ; Prescaler = Div by 4 (PRS4:0 = 1)
>
> RTS ; Return from subroutine
>
> CONVERT:LDAA #%00010110
> STAA ATDCTL5
> WTCONV: BRCLR ATDSTATH,#$80,WTCONV ; Wait for Sequence Complete Flag
> LDAA ADR2H ; Loads conversion result(ADR2H) into Accumulator
> LDAB ADR3H
> swi
> movb #%01111111,PWCLK ;CON01, clk A = PCLK/128, clk B = PCLK/128
> movb #$01,PWPOL ;source is clk A
> clr PWCTL
> clr PWTST
> movb #%00000011,PWEN ;enable PWEN0/1
> CBA
> ;swi
> BMI PWM1
> BPL PWM2
> jsr delay_1
> jmp CONVERT
> RTS ; Return from subroutine
>
> ;* -------------------------------
> ;* Subroutine DELAY 100 uS *
> ;* -------------------------------
> ; Delay Required for ATD converter to Stabilize (100 uSec)
>
> LDAA #$C8 ; Load Accumulator with "100 uSec delay value"
> DELAY: DECA ; Decrement ACC
> BNE DELAY ; Branch if not equal to Zero
> RTS ; Return from subroutine
>
> PWM1:
> movw #$0005,PWPER0 ;period
> movw #$0003,PWDTY0 ;duty
>
> RTS
> ;end of pwm1
> PWM2:
> movw #$0005,PWPER0 ;period
> movw #$0001,PWDTY0 ;duty
>
> RTS
> ; end of pwm
>
> delay_1:pshx
> movb #$90,TSCR
> movb #$03,TMSK2
> movb #$01,TIOS
> ldx #20
> ldd TCNTH
> again: addd #50000
> std TC0H
> brclr TFLG1,$01,*
> ldd TC0H
> dbne x,again
> pulx
> rts
> swi
> END ; End of program
>
> thank you.
> P.S. please help me with this issue asap.
>
> _
>

------------------------------------



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