gnupic: Re: [gnupic] CVS GPASM Preprocessor problem
Subject:
Re: [gnupic] CVS GPASM Preprocessor problem
From:
Robert Pearce ####@####.####
Date:
4 Sep 2007 22:19:24 +0100
Message-Id: <20070904221921.010af649.rob@bdt-home.demon.co.uk>
Hi James,
On Mon, 3 Sep 2007 18:31:40 -0400 you wrote:
>
> I'm having trouble with unpredictable output from the following preprocessor
> macro, which is designed to calculate an 8 or 16-bit BRG value:
>
> #define __CALCBAUD ((_FOSC/(.4*_SER_HIGHM*_SER_16BITM)*_SER_BAUD)-.1)
>
Unpredictable in what sense?
> _FOSC = .8000000
> _SER_HIGHM = .4
> _SER_16BITM = .1
>
> When _SER_BAUD is .38400, I'm expecting the result to be _
>
> HIGH __CALCBAUD evaluates to .191
> LOW __CALCBAUD evaluates to .255
>
And when I ran a quick test that was indeed what I got.
rob@zechariah ~/temp $ gpasm -v
gpasm-0.13.4 beta
rob@zechariah ~/temp $ head -n 30 test.lst
gpasm-0.13.4 beta test.asm 9-4-2007 22:14:34 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 list p=16f871
00002 radix dec
00003 include "p16f871.inc"
00001 LIST
00002 ; P16F871.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
00306 LIST
00004
00005
007A1200 00006 _FOSC equ .8000000
00000004 00007 _SER_HIGHM equ .4
00000001 00008 _SER_16BITM equ .1
00009
00010
00009600 00011 _SER_BAUD equ .38400
00012
00013 #define _CALCBAUD ((_FOSC/(.4*_SER_HIGHM*_SER_16BITM)*_SER_BAUD)-.1)
00014
0000 00015 org 0
00016
0000 30BF 00017 movlw high(_CALCBAUD)
0001 00A0 00018 movwf 0x20
0002 30FF 00019 movlw low(_CALCBAUD)
0003 00A1 00020 movwf 0x21
00021
rob@zechariah ~/temp $
What do you get?