problems with vectors on code section

Help
Med
2008-05-30
2013-03-12
  • Med
    Med
    2008-05-30

    Hi Guys, I have a problem and need your advice

    My programs is:

    __code static char s_bien[] = {'1','2','3','4'};

    void main (void)

    {
        Init_reg();
        EnableInterrupts;
        Init_TIM();
        Init_Uart();
        Sleep_ms(300);
        Send_Byte_Uart('M');

        while(1)
        {
            if (s_bien[0] == '1')
                Send_Byte_Uart('S');
            else
                Send_Byte_Uart('N');
           
            Sleep_ms(300);
        }
    }
    and I always get on Hyperterminal the leading M and a lots of N, I can't understand why I can't read the s_bien string good.

    Thanks in advance!
    Med

     
    • Maarten Brock
      Maarten Brock
      2008-06-02

      And the target is..... ?

       
    • Med
      Med
      2008-06-03

      Hi Maarten,

      Processor is Philips LPC932, I'm using

      SDCC_FLAGS = --compile-only --model-small --no-c-code-in-asm
      LFLAGS = --code-loc 0x0000 --data-loc 0x0008 --idata-loc 0x0080 --xram-loc 0x0000

      as flags

       
    • Maarten Brock
      Maarten Brock
      2008-06-03

      I see no reason why this should fail. Can you recompile/link without --no-c-code-in-asm and post the resulting .rst here, in the support tracker or on the user mailing list?

       
    • Med
      Med
      2008-06-03

      Maarten, I haven't .rst, I have .asm .ihx .sym and .lst, I will post .lst

                                    1 ;--------------------------------------------------------                              2 ; File Created by SDCC : free open source ANSI-C Compiler                              3 ; Version 2.8.1 #5187 (May 30 2008) (UNIX)                              4 ; This file was generated Tue Jun  3 11:27:13 2008                              5 ;--------------------------------------------------------                              6     .module main                              7     .optsdcc -mmcs51 --model-small                              8                                   9 ;--------------------------------------------------------                             10 ; Public variables in this module                             11 ;--------------------------------------------------------                             12     .globl _s_bien                             13     .globl _main                             14     .globl _P3_1                             15     .globl _P3_0                             16     .globl _P2_7                             17     .globl _P2_6                             18     .globl _P2_5                             19     .globl _P2_4                             20     .globl _P2_3                             21     .globl _P2_2                             22     .globl _P2_1                             23     .globl _P2_0                             24     .globl _T2EX                             25     .globl _T2                             26     .globl _P1_7                             27     .globl _P1_6                             28     .globl _P1_5                             29     .globl _P1_4                             30     .globl _P1_3                             31     .globl _P1_2                             32     .globl _P1_1                             33     .globl _P1_0                             34     .globl _CRSEL                             35     .globl _AA                             36     .globl _SI                             37     .globl _STO                             38     .globl _STA                             39     .globl _I2EN                             40     .globl _SM0                             41     .globl _SM1                             42     .globl _SM2                             43     .globl _REN                             44     .globl _TB8                             45     .globl _RB8                             46     .globl _TI                             47     .globl _RI                             48     .globl _PX0                             49     .globl _PT0                             50     .globl _PX1                             51     .globl _PT1                             52     .globl _PSR                             53     .globl _PS                             54     .globl _PB0                             55     .globl _PWDRT                             56     .globl _EI2C                             57     .globl _EKBI                             58     .globl _EC                             59     .globl _ESPI                             60     .globl _ECCU                             61     .globl _EST                             62     .globl _EIEE                             63     .globl _EA                             64     .globl _EWDRT                             65     .globl _EBO                             66     .globl _ES                             67     .globl _ET1                             68     .globl _EX1                             69     .globl _ET0                             70     .globl _EX0                             71     .globl _TF1                             72     .globl _TR1                             73     .globl _TF0                             74     .globl _TR0                             75     .globl _IE1                             76     .globl _IT1                             77     .globl _IE0                             78     .globl _IT0                             79     .globl _P0_7                             80     .globl _P0_6                             81     .globl _P0_5                             82     .globl _P0_4                             83     .globl _P0_3                             84     .globl _P0_2                             85     .globl _P0_1                             86     .globl _P0_0                             87     .globl _P                             88     .globl _F1                             89     .globl _OV                             90     .globl _RS0                             91     .globl _RS1                             92     .globl _F0                             93     .globl _AC                             94     .globl _CY                             95     .globl _WFEED2                             96     .globl _WFEED1                             97     .globl _WDL                             98     .globl _WDCON                             99     .globl _TRIM                            100     .globl _TPCR2L                            101     .globl _TPCR2H                            102     .globl _TOR2L                            103     .globl _TOR2H                            104     .globl _TMOD                            105     .globl _TL2                            106     .globl _TL1                            107     .globl _TL0                            108     .globl _TISE2                            109     .globl _TIFR2                            110     .globl _TICR2                            111     .globl _TH2                            112     .globl _TH1                            113     .globl _TH0                            114     .globl _TCR21                            115     .globl _TCR20                            116     .globl _TCON                            117     .globl _TAMOD                            118     .globl _SPDAT                            119     .globl _SPSTAT                            120     .globl _SPCTL                            121     .globl _SP                            122     .globl _SSTAT                            123     .globl _SCON                            124     .globl _SBUF                            125     .globl _SADEN                            126     .globl _SADDR                            127     .globl _RTCL                            128     .globl _RTCH                            129     .globl _RTCCON                            130     .globl _RSTSRC                            131     .globl _PT0AD                            132     .globl _PSW                            133     .globl _PCONA                            134     .globl _PCON                            135     .globl _P3M2                            136     .globl _P3M1                            137     .globl _P2M2                            138     .globl _P2M1                            139     .globl _P1M2                            140     .globl _P1M1                            141     .globl _P0M2                            142     .globl _P0M1                            143     .globl _P3                            144     .globl _P2                            145     .globl _P1                            146     .globl _P0                            147     .globl _OCRDL                            148     .globl _OCRDH                            149     .globl _OCRCL                            150     .globl _OCRCH                            151     .globl _OCRBL                            152     .globl _OCRBH                            153     .globl _OCRAL                            154     .globl _OCRAH                            155     .globl _KBPATN                            156     .globl _KBMASK                            157     .globl _KBCON                            158     .globl _IP1H                            159     .globl _IP1                            160     .globl _IP0H                            161     .globl _IP0                            162     .globl _IEN1                            163     .globl _IEN0                            164     .globl _ICRBL                            165     .globl _ICRBH                            166     .globl _ICRAL                            167     .globl _ICRAH                            168     .globl _I2STAT                            169     .globl _I2SCLL                            170     .globl _I2SCLH                            171     .globl _I2DAT                            172     .globl _I2CON                            173     .globl _I2ADR                            174     .globl _DPH                            175     .globl _DPL                            176     .globl _DIVM                            177     .globl _DEEADR                            178     .globl _DEEDAT                            179     .globl _DEECON                            180     .globl _CMP2                            181     .globl _CMP1                            182     .globl _CCCRD                            183     .globl _CCCRC                            184     .globl _CCCRB                            185     .globl _CCCRA                            186     .globl _BRGCON                            187     .globl _BRGR1                            188     .globl _BRGR0                            189     .globl _B                            190     .globl _AUXR1                            191     .globl _ACC                            192     .globl _ser_buf                            193     .globl _string_is_ready                            194     .globl _tt_main                            195     .globl _Init_reg                            196 ;--------------------------------------------------------                            197 ; special function registers                            198 ;--------------------------------------------------------                            199     .area RSEG    (DATA)                    00E0    200 _ACC    =    0x00e0                    00A2    201 _AUXR1    =    0x00a2                    00F0    202 _B    =    0x00f0                    00BE    203 _BRGR0    =    0x00be                    00BF    204 _BRGR1    =    0x00bf                    00BD    205 _BRGCON    =    0x00bd                    00EA    206 _CCCRA    =    0x00ea                    00EB    207 _CCCRB    =    0x00eb                    00EC    208 _CCCRC    =    0x00ec                    00ED    209 _CCCRD    =    0x00ed                    00AC    210 _CMP1    =    0x00ac                    00AD    211 _CMP2    =    0x00ad                    00F1    212 _DEECON    =    0x00f1                    00F2    213 _DEEDAT    =    0x00f2                    00F3    214 _DEEADR    =    0x00f3                    0095    215 _DIVM    =    0x0095                    0082    216 _DPL    =    0x0082                    0083    217 _DPH    =    0x0083                    00DB    218 _I2ADR    =    0x00db                    00D8    219 _I2CON    =    0x00d8                    00DA    220 _I2DAT    =    0x00da                    00DD    221 _I2SCLH    =    0x00dd                    00DC    222 _I2SCLL    =    0x00dc                    00D9    223 _I2STAT    =    0x00d9                    00AB    224 _ICRAH    =    0x00ab                    00AA    225 _ICRAL    =    0x00aa                    00AF    226 _ICRBH    =    0x00af                    00AE    227 _ICRBL    =    0x00ae                    00A8    228 _IEN0    =    0x00a8                    00E8    229 _IEN1    =    0x00e8                    00B8    230 _IP0    =    0x00b8                    00B7    231 _IP0H    =    0x00b7                    00F8    232 _IP1    =    0x00f8                    00F7    233 _IP1H    =    0x00f7                    0094    234 _KBCON    =    0x0094                    0086    235 _KBMASK    =    0x0086                    0093    236 _KBPATN    =    0x0093                    00EF    237 _OCRAH    =    0x00ef                    00EE    238 _OCRAL    =    0x00ee                    00FB    239 _OCRBH    =    0x00fb                    00FA    240 _OCRBL    =    0x00fa                    00FD    241 _OCRCH    =    0x00fd                    00FC    242 _OCRCL    =    0x00fc                    00FF    243 _OCRDH    =    0x00ff                    00FE    244 _OCRDL    =    0x00fe                    0080    245 _P0    =    0x0080                    0090    246 _P1    =    0x0090                    00A0    247 _P2    =    0x00a0                    00B0    248 _P3    =    0x00b0                    0084    249 _P0M1    =    0x0084                    0085    250 _P0M2    =    0x0085                    0091    251 _P1M1    =    0x0091                    0092    252 _P1M2    =    0x0092                    00A4    253 _P2M1    =    0x00a4                    00A5    254 _P2M2    =    0x00a5                    00B1    255 _P3M1    =    0x00b1                    00B2    256 _P3M2    =    0x00b2                    0087    257 _PCON    =    0x0087                    00B5    258 _PCONA    =    0x00b5                    00D0    259 _PSW    =    0x00d0                    00F6    260 _PT0AD    =    0x00f6                    00DF    261 _RSTSRC    =    0x00df                    00D1    262 _RTCCON    =    0x00d1                    00D2    263 _RTCH    =    0x00d2                    00D3    264 _RTCL    =    0x00d3                    00A9    265 _SADDR    =    0x00a9                    00B9    266 _SADEN    =    0x00b9                    0099    267 _SBUF    =    0x0099                    0098    268 _SCON    =    0x0098                    00BA    269 _SSTAT    =    0x00ba                    0081    270 _SP    =    0x0081                    00E2    271 _SPCTL    =    0x00e2                    00E1    272 _SPSTAT    =    0x00e1                    00E3    273 _SPDAT    =    0x00e3                    008F    274 _TAMOD    =    0x008f                    0088    275 _TCON    =    0x0088                    00C8    276 _TCR20    =    0x00c8                    00F9    277 _TCR21    =    0x00f9                    008C    278 _TH0    =    0x008c                    008D    279 _TH1    =    0x008d                    00CD    280 _TH2    =    0x00cd                    00C9    281 _TICR2    =    0x00c9                    00E9    282 _TIFR2    =    0x00e9                    00DE    283 _TISE2    =    0x00de                    008A    284 _TL0    =    0x008a                    008B    285 _TL1    =    0x008b                    00CC    286 _TL2    =    0x00cc                    0089    287 _TMOD    =    0x0089                    00CF    288 _TOR2H    =    0x00cf                    00CE    289 _TOR2L    =    0x00ce                    00CB    290 _TPCR2H    =    0x00cb                    00CA    291 _TPCR2L    =    0x00ca                    0096    292 _TRIM    =    0x0096                    00A7    293 _WDCON    =    0x00a7                    00C1    294 _WDL    =    0x00c1                    00C2    295 _WFEED1    =    0x00c2                    00C3    296 _WFEED2    =    0x00c3                            297 ;--------------------------------------------------------                            298 ; special function bits                            299 ;--------------------------------------------------------                            300     .area RSEG    (DATA)                    00D7    301 _CY    =    0x00d7                    00D6    302 _AC    =    0x00d6                    00D5    303 _F0    =    0x00d5                    00D4    304 _RS1    =    0x00d4                    00D3    305 _RS0    =    0x00d3                    00D2    306 _OV    =    0x00d2                    00D1    307 _F1    =    0x00d1                    00D0    308 _P    =    0x00d0                    0080    309 _P0_0    =    0x0080 _P0_1_P0_2_P0_3_P0_4_P0_5_P0_6_P0_7_IT0_IE0_IT1_IE1_TR0_TF0_TR1_TF1_EX0_ET0_EX1_ET1_ES_EBO_EWDRT_EA_EIEE_EST_ECCU_ESPI_EC_EKBI_EI2C_PWDRT_PB0_PS_PSR_PT1_PX1_PT0_PX0_RI_TI_RB8_TB8_REN_SM2_SM1_SM0_I2EN_STA_STO_SI_AA_CRSEL_P1_0_P1_1_P1_2_P1_3_P1_4_P1_5_P1_6_P1_7_T2_T2EX_P2_0_P2_1_P2_2_P2_3_P2_4_P2_5_P2_6_P2_7_P3_0_P3_1_BANK_0(REL,OVR,DATA)(DATA)_tt_main::_string_is_ready::_ser_buf::(OVR,DATA)(DATA)__start__stack:(DATA)(ABS,DATA)(ABS,DATA)(BIT)(PAG,XDATA)(XDATA)(ABS,XDATA)(XDATA)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)(CODE)__interrupt_vect:__sdcc_gsinit_startup_timer0_uart_handler(CODE)(CODE)(CODE)(CODE)__sdcc_gsinit_startup__sdcc_program_startup__start__stack__mcs51_genXINIT__mcs51_genXRAMCLEAR__mcs51_genRAMCLEAR(CODE)__sdcc_program_startup(CODE)(CODE)__sdcc_program_startup:_main(CODE)(void)_main:_reg();_Init_reg_EA_TIM();_Init_TIM_Uart();_Init_Uart_ms(300);#0x012C_Sleep_ms_Byte_Uart('M');#0x4D_Send_Byte_Uart(1)(s_bien[0] == '1')#_s_bien#0x31,00102$_Byte_Uart('S');#0x53_Send_Byte_Uart_Byte_Uart('N');#0x4E_Send_Byte_Uart_ms(300);#0x012C_Sleep_ms_reg'_reg(void)_reg_Init_reg:_DIVM,#0x00_TRIM,#0xBF(CPU clock faster than 8MHz)_AUXR1,#0x7F_PCON,#0x00_PCONA,#0x00_TMOD,#0x00_TAMOD,#0x00_TCON,#0x00_IEN0,#0x00_IEN1,#0x00_IP0,#0x00_IP0H,#0x00_IP1,#0x00_IP1H,#0x00_SPCTL,#0x00_CMP1,#0x00_CMP2,#0x00_P0M1,#0x48_P0M2,#0xB7_P1M1,#0x00_P1M2,#0xFD_P2M1,#0x00_P2M2,#0xC1(CODE)(CODE)_s_bien:#0x31#0x32#0x33#0x34(CODE)(ABS,CODE)

      Thats all

       
    • Maarten Brock
      Maarten Brock
      2008-06-04

      The list looks fine. Is your target mcu locked in any way?

       
    • Med
      Med
      2008-06-04

      No Maartin, thats the strange thing.

      I made this code anly as sample for look the solution to my problem, but I face the same reading the memory and sending on the spi (always sends as zeroes), reading a table to drive a 7 segment display, and so on.

      I download the sdcc on binary form, will be useful to download the sdcc code and compile on my system?

      Thanks

       
    • Maarten Brock
      Maarten Brock
      2008-06-05

      Recompiling the compiler yourself will not bring you anything different.

      But have a look at this:
      http://www.8052.com/forum/read.phtml?id=72973

      It seems the LPC932 is (was) a flawed device. Search for the device, the datasheet, the errata and maybe you'll find more.

       
    • Med
      Med
      2008-06-05

      Maarten you are right about the LPC932, knowing this isues we are using the LPC932A1.

      http://www.8052.com/forum/read.phtml?id=73071

      It must be something in my compiler, I remember that with the version 2.4.0 was able to read the memory, sometime ago I install the 2.8.0  then when I saw these problems in my code try to get back to 2.4.0 but my programs never read the code sections again.

      It's posible that my old linux be the problem?