Jump to content

Recommended Posts

I am working on a SMBuss project that targets the PIC18F27J53 using the BoostC (ver7.04) in MPLAB (ver8.87). I am using a 256 byte lookup table for generating the CRC (PEC). The lookup table is not generating the correct offset and I'm not sure why. I have generalized the problem to reduce confusion. In the main while() loop I have "crc=CRC8LKUP[0xB4] ;" when I look at the listing file, line 134, the index is changed from 0xB4 to 0x68. Attached are the relivant files. Anybody have an idea what is going on?

 

;/////////////////////////////////////////////////////////////////////////////////
;// Code Generator: BoostC Compiler - http://www.sourceboost.com
;// Version : 7.04
;// License Type : Standard License
;// Limitations : PIC18 max code size:16384 bytes, max RAM banks:Unlimited, Non commercial use only
;/////////////////////////////////////////////////////////////////////////////////

ORG 0x00000000
0000 EFA0F000 GOTO _startup
ORG 0x00000008
0008 __rom_get_00000
0008 ; { __rom_get ; function begin
0008 5005 MOVF __rom_get_00000_arg_idx, W
000A 6E08 MOVWF __rom_get_00000_1_romAddr+D'2'
000C 0E00 MOVLW UPPER( label1 )
000E 6EF8 MOVWF TBLPTRU
0010 0E00 MOVLW HIGH( label1 )
0012 6EF7 MOVWF TBLPTRH
0014 0E2A MOVLW LOW( label1 )
0016 6EF6 MOVWF TBLPTRL
0018 5008 MOVF __rom_get_00000_1_romAddr+D'2', W
001A 26F6 ADDWF TBLPTRL, F
001C B0D8 BTFSC STATUS,C
001E 2AF7 INCF TBLPTRH, F
0020 B0D8 BTFSC STATUS,C
0022 2AF8 INCF TBLPTRU, F
0024 0008 TBLRD*
0026 50F5 MOVF TABLAT, W
0028 0012 RETURN
002A label1
002A 0700 DW 0x0700
002C 090E DW 0x090E
002E 1B1C DW 0x1B1C
0030 1512 DW 0x1512
0032 3F38 DW 0x3F38
0034 3136 DW 0x3136
0036 2324 DW 0x2324
0038 2D2A DW 0x2D2A
003A 7770 DW 0x7770
003C 797E DW 0x797E
003E 6B6C DW 0x6B6C
0040 6562 DW 0x6562
0042 4F48 DW 0x4F48
0044 4146 DW 0x4146
0046 5354 DW 0x5354
0048 5D5A DW 0x5D5A
004A E7E0 DW 0xE7E0
004C E9EE DW 0xE9EE
004E FBFC DW 0xFBFC
0050 F5F2 DW 0xF5F2
0052 DFD8 DW 0xDFD8
0054 D1D6 DW 0xD1D6
0056 C3C4 DW 0xC3C4
0058 CDCA DW 0xCDCA
005A 9790 DW 0x9790
005C 999E DW 0x999E
005E 8B8C DW 0x8B8C
0060 8582 DW 0x8582
0062 AFA8 DW 0xAFA8
0064 A1A6 DW 0xA1A6
0066 B3B4 DW 0xB3B4
0068 BDBA DW 0xBDBA
006A C0C7 DW 0xC0C7
006C CEC9 DW 0xCEC9
006E DCDB DW 0xDCDB
0070 D2D5 DW 0xD2D5
0072 F8FF DW 0xF8FF
0074 F6F1 DW 0xF6F1
0076 E4E3 DW 0xE4E3
0078 EAED DW 0xEAED
007A B0B7 DW 0xB0B7
007C BEB9 DW 0xBEB9
007E ACAB DW 0xACAB
0080 A2A5 DW 0xA2A5
0082 888F DW 0x888F
0084 8681 DW 0x8681
0086 9493 DW 0x9493
0088 9A9D DW 0x9A9D
008A 2027 DW 0x2027
008C 2E29 DW 0x2E29
008E 3C3B DW 0x3C3B
0090 3235 DW 0x3235
0092 181F DW 0x181F
0094 1611 DW 0x1611
0096 0403 DW 0x0403
0098 0A0D DW 0x0A0D
009A 5057 DW 0x5057
009C 5E59 DW 0x5E59
009E 4C4B DW 0x4C4B
00A0 4245 DW 0x4245
00A2 686F DW 0x686F
00A4 6661 DW 0x6661
00A6 7473 DW 0x7473
00A8 7A7D DW 0x7A7D
00AA 8E89 DW 0x8E89
00AC 8087 DW 0x8087
00AE 9295 DW 0x9295
00B0 9C9B DW 0x9C9B
00B2 B6B1 DW 0xB6B1
00B4 B8BF DW 0xB8BF
00B6 AAAD DW 0xAAAD
00B8 A4A3 DW 0xA4A3
00BA FEF9 DW 0xFEF9
00BC F0F7 DW 0xF0F7
00BE E2E5 DW 0xE2E5
00C0 ECEB DW 0xECEB
00C2 C6C1 DW 0xC6C1
00C4 C8CF DW 0xC8CF
00C6 DADD DW 0xDADD
00C8 D4D3 DW 0xD4D3
00CA 6E69 DW 0x6E69
00CC 6067 DW 0x6067
00CE 7275 DW 0x7275
00D0 7C7B DW 0x7C7B
00D2 5651 DW 0x5651
00D4 585F DW 0x585F
00D6 4A4D DW 0x4A4D
00D8 4443 DW 0x4443
00DA 1E19 DW 0x1E19
00DC 1017 DW 0x1017
00DE 0205 DW 0x0205
00E0 0C0B DW 0x0C0B
00E2 2621 DW 0x2621
00E4 282F DW 0x282F
00E6 3A3D DW 0x3A3D
00E8 3433 DW 0x3433
00EA 494E DW 0x494E
00EC 4740 DW 0x4740
00EE 5552 DW 0x5552
00F0 5B5C DW 0x5B5C
00F2 7176 DW 0x7176
00F4 7F78 DW 0x7F78
00F6 6D6A DW 0x6D6A
00F8 6364 DW 0x6364
00FA 393E DW 0x393E
00FC 3730 DW 0x3730
00FE 2522 DW 0x2522
0100 2B2C DW 0x2B2C
0102 0106 DW 0x0106
0104 0F08 DW 0x0F08
0106 1D1A DW 0x1D1A
0108 1314 DW 0x1314
010A A9AE DW 0xA9AE
010C A7A0 DW 0xA7A0
010E B5B2 DW 0xB5B2
0110 BBBC DW 0xBBBC
0112 9196 DW 0x9196
0114 9F98 DW 0x9F98
0116 8D8A DW 0x8D8A
0118 8384 DW 0x8384
011A D9DE DW 0xD9DE
011C D7D0 DW 0xD7D0
011E C5C2 DW 0xC5C2
0120 CBCC DW 0xCBCC
0122 E1E6 DW 0xE1E6
0124 EFE8 DW 0xEFE8
0126 FDFA DW 0xFDFA
0128 F3F4 DW 0xF3F4
012A ; } __rom_get function end

ORG 0x0000012A
012A main
012A ; { main ; function begin
012A 6A01 CLRF gbl_3_x
012C 6A02 CLRF gbl_3_x+D'1'
012E label2
012E 0101 MOVLB 0x01
0130 5100 MOVF gbl_CRC8LKUP, W, 1
0132 6E04 MOVWF __rom_get_00000_arg_objNumb
0134 0E68 MOVLW 0x68
0136 6E05 MOVWF __rom_get_00000_arg_idx
0138 EC04F000 CALL __rom_get_00000
013C 6E03 MOVWF gbl_3_crc
013E D7F7 BRA label2
0140 ; } main function end

ORG 0x00000140
0140 _startup
0140 0E00 MOVLW 0x00
0142 0101 MOVLB 0x01
0144 6F00 MOVWF gbl_CRC8LKUP, 1
0146 6A01 CLRF gbl_3_x
0148 6A02 CLRF gbl_3_x+D'1'
014A 6A03 CLRF gbl_3_crc
014C EF95F000 GOTO main
ORG 0x0001FFF8
1FFF8 071C DW 0x071C
1FFFA 0018 DW 0x0018
1FFFC 0000 DW 0x0000
1FFFE 0980 DW 0x0980

 

MAIN.C

CRC8.H

IC.H

Share this post


Link to post
Share on other sites

Not sure what the differences are between these two ways of declaring a ROM table

 

rom char *MYTABLE[] = { somedata } ; // Compiler generates code to double the value you give, as if all elements in the table are word aligned

or

rom const char[] = { somedata } ; // Compiler allows elements in table to be accessed using byte alignment

 

Any insite? I found my fix so this thread is done.

Share this post


Link to post
Share on other sites

Hi

 

Probably this happens because you are using a PIC that can do self-write of program flash memory.

So when you don't use the "const" modifier it aligns the data in a way that's compatible with a simple program flash write procedure.

 

I'm more or less gessing, but it makes sense for me.

 

Best regards

Jorge

Share this post


Link to post
Share on other sites

Just got burned again on an 18F2620:

If I use:

rom const char table[]= { ....}; 

it chews up RAM

If I use:

rom const char *table = {....}; it does not chew up RAM

Using Version 7.22.  It is bad enough that I have to break my tables up into tiny 256 byte pieces but until I found this secret, I was ready to go to the dark side (Microchip compiler).

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×