This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need help for STM32F103ZGT6 in Keil. Have reset problems. Please help.

Hello,

I am working on STM32F103ZGT6 with Keil Compiler. The version of Keil & other info are as below,
IDE-Version:
µVision V4.23.00.0

Tool Version Numbers:
Toolchain: MDK-ARM Standard Version: 4.23
Toolchain Path: C:\Keil\ARM\BIN40
C Compiler: Armcc.Exe V4.1.0.894
Assembler: Armasm.Exe V4.1.0.894
Linker/Locator: ArmLink.Exe V4.1.0.894
Librarian: ArmAr.Exe V4.1.0.894
Hex Converter: FromElf.Exe V4.1.0.894
CPU DLL: SARMCM3.DLL V4.23
Dialog DLL: DARMSTM.DLL V1.63.0.0
Target DLL: UL2CM3.DLL V1.95
Dialog DLL: TARMSTM.DLL V1.60

I am facing a weird problem, that STm32 is resetting for the smallest change in Code.

For example :
#define GuiConst_DISPLAY_WIDTH_test 480
#define GuiConst_BYTE_LINES_test 272
#define GuiConst_DISPLAY_BYTES_test (GuiConst_DISPLAY_WIDTH_test*GuiConst_BYTE_LINES_test)

And somewhere in my code, I have statements as below. for(i = 0; i < (GuiConst_DISPLAY_BYTES_test); i++) { LCD_Data_Disp_Transfer(k); }
, If the above code is present, the micro is working properly, where "GuiConst_DISPLAY_BYTES_test" is a Macro as defined above.

If I change it to "GuiConst_DISPLAY_WIDTH_test" in "for" loop, the STM32 starts resetting once it is in Debug Mode, it resets automatically every one sec automatically. Actually it is not reaching till this "for" loop at all. I can see that, it is entering into "main()", but after executing some functions in "main()", it resets automatically.

Can you please tell me, what could be the problem.
Should I have to update Keil, for this new STM32F103ZT6. Please guide me.. I have wasted lot of time in trail and error.

I have just posted an example where it is affecting.. But actually it is affecting in many more places. For many more changes. it is becoming difficult for me to do any changes and debug my development.

Rgds
Shankar B T
shankar.tangai@ika.in

Parents
  • If its just changing the display size as a first swag ( stupid wild *** guess) I would say check either task stack sizes or arrays that you use related to the GUI.

    e.g. 272*480 = 130560 bytes if using 8 bit colour.
    e.g. 272*480 = 261120 bytes if using 16 bit colour.

    Doesnt STM32F103 device only have a max of 96K - so have you defined the external RAM area correctly to drive this display ?

Reply
  • If its just changing the display size as a first swag ( stupid wild *** guess) I would say check either task stack sizes or arrays that you use related to the GUI.

    e.g. 272*480 = 130560 bytes if using 8 bit colour.
    e.g. 272*480 = 261120 bytes if using 16 bit colour.

    Doesnt STM32F103 device only have a max of 96K - so have you defined the external RAM area correctly to drive this display ?

Children
  • With big loops like that, is the Watchdog biting...?

  • Hello,

    Thanks for your reply.

    Actually, this is not only instance what is causing the problem. This error is very weird. AS you can see "GuiConst_DISPLAY_BYTES_test" = (480*272), because the value "k" what I am passing is 16Bit Color Code data -------LCD_Data_Disp_Transfer(k);---------. And you can refer the Macro's defined. This is not the problem of the number of Bytes I am transferring.

    There are many other instances too.

    I did many analysis now and feel that this might be Stack related problem. I cant explain my analysis now as it is too much.

    So how can u say that the below part of code works properly without making reset for(j = 0; j < 90; j++) { for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(color); } for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(0xF000); } for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(0x003F); } }
    --- in above part of code I am writing (90*3 = 270) lines of TFT. This is working and STM32 doesn't reset.

    When I change the above code as below, this reset the STM32, it starts resetting contimously and actually when I put BreakPoint, it doesn't hit the starting for loop at all. The execution doesn't come till here at all. This is strange - for(j = 0; j < 68; j++) { for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(color); } for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(0xF000); } for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(0x003F); } for(i = 0; i <= 480; i++) { LCD_Data_Disp_Transfer(0x0FFF); } }
    --- In the above part of code, I am writing (68*4 = 272) lines of TFT (Full TFT). But the above resets the STM32..

    So I feel, somewhere stack is affected and not properly Initialzed.

    For your reference I am sharing scatter file details..
    LR_IROM1 0x8008000 0x00100000 { ; load region size_region ER_IROM1 0x8008000 0x00100000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00010000 { ; RW data .ANY (+RW +ZI) } EXT_RAM2 0x60020000 0x0040000 { ; RW data * (ZI) }

    The below query is different from the above -
    I surely feel it is nothing to do with size of allocation. But I need some help in setting the external memory to this display buffer.
    The below code explains it
    #ifdef GuiConst_COLOR_DEPTH_16
    typedef union
    { GuiConst_INT8U Bytes[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE]; GuiConst_INT16U Words[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE / 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf __attribute__((section("ZI"))); #define EXT_RAM2 0x62020000
    #endif

    When I think of using this buffer to write onto TFT, I am not able to write into this buffer, it contains some junk value and that data is written onto TFT. So, can u tell me, where would this Buffer be allocated in STM32.. (RAM or ROM or FLASH). It should be in RAM, but the size of RAM for STM32 is 96K, where this buffer needs 261120 bytes. So I think this should be allocated in EXT_MEM Location 0x60000000, you can refer the scatter file details above for this to help me.

    Can you also please tell me, how to set the stack & heap size and anything else related to this..

    Thanks
    Shankar

  • Thanks Andrew,

    Please follow this link as I have replyed to Danny,

    I have not set WatchDog. It is disabled.
    I feel it is B'coz of Stack, something related to stack.

    Please follow the post for more information. Please try to help me how to Set or Initialize Stack for STM32.

    Thanks
    Shankar

  • You are posting gibberish when you don't make use of the "pre" tags for code - notice how all line breaks and indentation are lost.

    for(i = 0; i <= 480; i++)
    

    Note that this loop is wrong, if you have a buffer dimensioned for 480 scan lines - the loop processes 481 lines, not 480.

  • Hello,

    Thanks for the reply..

    I understand your comment. Actually it is working fine with this for loop.
    the TFt is 480 Width and 272 Lines.

    480(Width)
    -----------------------------------
    | |
    | |
    | 272(lines) |
    | |
    | |
    | |
    -----------------------------------

    I dont have problem with this "for" loop, I am getting proper colors on TFT in every line. earlier I had condition "<480" & not "<=480", the Pixels were disturbed on TFT.

    Actually, STM32 is resetting by itself every one second (approximately). The issue is not with the TFT data transfer. But I feel, it is about allocating Ext RAM for this Display Buffer, which is taking more memory than 96Kb (SRAM)of STM32. There is a feature of FSMC or Ext RAM in STM32, which is located at 0x60000000 (Bank1). I have not set this configuration and I want my Display Buffer data to me moved to this Ext RAM and from where I can access my display data or write into it.

    I want to know, how to allocate this location or access it.

    Rgds
    Shankar

  • It is irrelevant if 480 is height or width. Your loop do 481 steps. What memory gets accessed by that?

    If display looks wrong if you write 480 instead of 481 columns: don't you think that is a reason to try to figure out what is wrong instead of just increasing the number of columns written?

  • Hmm..

    I understand what u r telling..

    But if you see my code in the explainations above, I am not accessing any memory or buffer. They are direct values (constant) values. Currently I am just using GPIO pins to transfer the data.

    LCD_Data_Disp_Transfer(0x003F); -------- Where 0x003F is the Color code for displaying RED.

    F.Y.I
    void LCD_Data_Disp_Transfer(void)
    { GPIOD->BRR = GPIO_Pin_7; //CHIP_ENABLED; GPIOD->BSRR = GPIO_Pin_11; //MODE_DATA; GPIOD->BSRR = GPIO_Pin_4; //RD_HIGH;

    //Write data GPIOD->ODR = (GPIOD->ODR & 0x38FC) | ((value&1) << 14) | ((value&2) << 14) | ((value&4) >> 2) | ((value&8) >> 2) | ((value&0x8000) >> 5) | ((value&0x4000) >> 5) | ((value&0x2000) >> 5);

    GPIOE->ODR = (GPIOE->ODR & 0x007F) | ((value&16) << 3) | ((value&32) << 3) | ((value&64) << 3) | ((value&128) << 3) | ((value&256) << 3) | ((value&512) << 3) | ((value&1024) << 3) | ((value&2048) << 3) | ((value&4096) << 3);

    GPIOD->BRR = GPIO_Pin_5; //WR_LOW; // millisecond_delay(1); GPIOD->BSRR = GPIO_Pin_5; //WR_HIGH; GPIOD->BSRR = GPIO_Pin_7; //CHIP_DISABLED;
    }

    The Display Buffer is just defined, but I am not using it in my Software.

    Just now I did a small Analysis, I cahnged the size of Display Buffer
    as below -
    Earlier
    typedef union
    { GuiConst_INT8U Bytes[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE]; GuiConst_INT16U Words[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE/ 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf

    --------------------
    After Changing
    typedef union
    { GuiConst_INT8U Bytes[GuiConst_BYTE_LINES][10]; GuiConst_INT16U Words[GuiConst_BYTE_LINES][10/ 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf

    -----------------------------
    The changes done to the size of Display Buffer is working fine. So, I need help to Configure this Display Buffer to External memory location of STM32 which is allocated at address 0x60000000 (FSMC Bank 1). i think we should do this by using __attribute__((section xyz)), in scatter file. I dont know much about this and how to use..

    Thanks
    Shankar

  • STM32F10x_StdPeriph_Lib\Project\STM32F10x_StdPeriph_Examples\FSMC.

  • Thanku Danny,

    I need direct help now,

    I guess now I am able to allocate the RAM location for the Display Buffer by doing it as below.

    In .h File
    typedef union
    { GuiConst_INT8U Bytes[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE]; GuiConst_INT16U Words[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE/ 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf __attribute__((at(0x62020000)));

    In scatter File I am not sure, whether the cahnges are properly done.
    LR_IROM1 0x8008000 0x00100000
    { ; load region size_region ER_IROM1 0x8008000 0x00100000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x00010000 { ; RW data .ANY (+RW +ZI) } EXT_RAM2 0x62020000 0x0080000 { ; RW data * (ZI) }
    }

    Please check this, I am getting a warning after Software Build, warning is as below

    .\ST\stm32_testprojekt.sct(15): warning: L6314W: No section matches pattern *(ZI).

    But, at the moment, I am able to program STM32 and see the Display with Colors Directly.

    I am not able to write anything into the Display Buffer or always has the value 0x0000 in it.. Hope I dont have right to write into Display Buffer array or it might not be activated(location 0x60000000). Please let me know..

    Thanks
    Shankar

  • I wrote in an earlier post:
    "You are posting gibberish when you don't make use of the "pre" tags for code - notice how all line breaks and indentation are lost."

    Any reason why you continue to post code that gets the formatting completely garbled? Don't you think it might be a good idea to look at the "Tips for Posting Messages" visible directly above the message input box?

    Posting hard-to-read code means less people will care to spend time reading it. So less people who will care to help.

  • Oh Sorry, I didnt realise it..

    Danny, please go throught the info below.
    I need direct help now,

    I guess now I am able to allocate the RAM location for the Display Buffer by doing it as below.

    In .h File

    typedef union
    {
            GuiConst_INT8U  Bytes[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE];
            GuiConst_INT16U Words[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE/ 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf __attribute__((at(0x62020000)));
    

    In scatter File I am not sure, whether the cahnges are properly done.

    LR_IROM1 0x8008000 0x00100000
    {               ; load region size_region
            ER_IROM1 0x8008000 0x00100000
            {               ; load address = execution address
                    *.o (RESET, +First)
                    *(InRoot$$Sections)
                    .ANY (+RO)
            }
            RW_IRAM1 0x20000000 0x00010000
            {               ; RW data
                    .ANY (+RW +ZI)
            }
            EXT_RAM2 0x62020000 0x0080000
            {  ; RW data
                    * (ZI)
            }
    }
    


    Please check this, I am getting a warning after Software Build, warning is as below

    .\ST\stm32_testprojekt.sct(15): warning: L6314W: No section matches pattern *(ZI).
    

    But, at the moment, I am able to program STM32 and see the Display with Colors Directly.

    I am not able to write anything into the Display Buffer or always has the value 0x0000 in it.. Hope I dont have right to write into Display Buffer array or it might not be activated(location 0x60000000). Please let me know..

  • You don't need a scatter file for variables placed at absolute addresses.

    You can use a scatter file for forcing placing of things, but you then use some naming scheme to match the code or variables in your program to the relevant zones specified in the scatter file.

    Another thing - depending on what memory regions you use and if you want the data initialized before reaching main(), you may have to adjust the startup file to make sure that the specific memory regions are powered up and enabled. So if using memory areas in external memory, then the startup file must get the memory controller configuration for that external RAM. If using RAM located in a peripherial device, that peripherial may need to be powered up so the RAM block is powered up and accessible.

    In your case, you have a rule for .ANY (+ZI) for RW_IRAM1. What would match your rule in EXT_RAM2?

  • If you look a the two examples you see they tell you how to set up the hardware and the Keil enviroment to use an external SRAM

    SRAM This example provides a basic example of how to use the FSMC firmware library and an associate driver to perform read/write operations on the IS61WV51216BLL SRAM memory mounted on STM3210E-EVAL board.

    SRAM DataMemory This example shows how to use the external SRAM mounted on STM3210E-EVAL or
    STM32100E-EVAL board as program data memory and internal SRAM for Stack.

    In each of the example directories there is a readme file listing the steps.

    I dont work with the STM32F10X family on a day to day basis so am not really able to advise you much more than to point you at ST provided examples set up for the Keil Tools.

    Sorry

  • Hmm,

    I am quite confused about these settings.

    In STM32 there is a Memory Space "FSMC bank1 & bank2", which is located at location 0x60000000 till 0x6FFFFFFF. As the SRAM size of STM32103FZGT6 is 96K, I feel, I need more RAM to store the Display Data, which is in "GuiLib_DisplayBuf[][]" of size 261120 bytes.

    Frankly telling, I dont have much idea of Scatter File.

    I just want a solution for allocating the variable "GuiLib_DisplayBuf[][]" to FSMC bank location of STM32. During declaration of "GuiLib_DisplayBuf[][]" as below I have allocated it to 0x60020000.

    typedef union
    {
            GuiConst_INT8U  Bytes[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE];
            GuiConst_INT16U Words[GuiConst_BYTE_LINES][GuiConst_BYTES_PR_LINE/ 2];
    } DisplayBufUnion;
    extern DisplayBufUnion GuiLib_DisplayBuf __attribute__((at(0x60020000)));
    

    After doing this, i am getting a warning

    .\ST\stm32_testprojekt.sct(19): warning: L6314W: No section matches pattern *(ZI).
    

    with build details

    Program Size: Code=46242 RO-data=38542 RW-data=316 ZI-data=408852
    


    I dont know exactly, what is this ZI.

    Now, I want to know what changes should be done in scatter file or any other file.

    Rgds
    Shankar

  • No. It isn't your line:

    extern DisplayBufUnion GuiLib_DisplayBuf __attribute__((at(0x60020000)));
    


    that is generating the warning.

    It's your change to the scatter file that is generating the warning.

    ZI, by the way, stands for zero-initialized variables.

    Why do you manually create a scatter file, unless you use any features that requiers a scatter file? If you use your "at" declaration in the code, and add the address range of your external RAM in the project settings, you can ignore that scatter file.

    But whatever you do, you must make sure that the startup file configures the memory controller for that external RAM range.