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

Array initialization in c8051F320

I'm trying to fill an array in xdata with zeros as follows:

unsigned char n; //Index to scan the array
unsigned char xdata bt[100]; //The array to fill

for(n=0;n<100;n++){ bt[n]=0; }

But when the array size is bigger than 38 elements the MCU hangs.
Does anybody know the reason why this happens?

Parents Reply Children
  • When the MCU start I create the variables in xdata memory, well.

  • I'm unable to post any further message...

  • When I create such a big arrays into xdata the system takes to long and WDT expires causing a CPU reset. Obviously the first thing I do in main() is to disable the WDT but it's too late. So it looks like despite I've got 2k of RAM I cannot use this memory for global arrays that are bigger than 20bytes, as I I do that the WDT will reset the MCU.
    Does anybody know how can I avoid WDT operation to take place before I got the control into the main()? Is it possible that Silab made such a beautiful memory bank but it's impossible to use for such a thing?

  • It is possible to create longer messages on this forum - and notice it's a forum and not a blog.

    The issue is that there have been lots of spam issues. And for some reason, the word w_a_t_c_h_d_o_g just happens to trig their spam filter, giving you the error messages you are seeing. Or you might have accidentally found some other trigger word.

    I think this was one of several threads where I did try to warn about the w-dog issues but wasn't allowed to post.

  • I've got 2k of RAM . not off the bat, you have 1k + 1k "USB memory" I think to recall that there is some configuration that you have to do in startup.a51 that will make the "USB memory" usable as regular RAM, check the datasheet

    Obviously the first thing I do in main() is to disable the WDT but it's too late
    That is why I tell EVERYBODY to do it in startup.a51

  • Hi Eric,
    I will try to avoid to trigger the black-listed word in this forum.
    Well, I have modified STARTUP.A51 including ASM instructions to disable WDT before the memory is allocated. Now everything seems to work fine, no more strange behaviour.
    I'm using 1K of XDATA, 128byte DATA and 128byte iDATA. I'm wondering if you can suggest some setting to gain access to USB 1K FIFO. F320 is quite powerful and despite it's age is still a winning choice against many other MCU thanks to the powerful peripherals such as ADC, DAC, PWM, SPI, and so on. However the RAM limitation still makes difference in some very specific cases. Having 2304byte of RAM would open the way to several additional applications.
    I've checked in the user manual and specs but I've not found any specific and explicit instruction to control the 1k FIFO. I understood that this memeory is fully controlled by USB logic hence it would be hard to control from 8051 core. There might be some instruction to push/pop data into FIFO, this could be useful but far away from a clasic RAM access operation.

  • I'm wondering if you can suggest some setting to gain access to USB 1K FIFO.
    I could read the datsheet for you, but naah

  • Hi Erik,
    I did the change, and it worked!
    I added few rows in ASM to disable WDT and it's working great now.
    The news that I've got another 1K of RAM sounds amazing for my applications. It look like this RAM is hidden by my ignorance and nothing else. I've looked trough the datasheet of Silab c8051F320 and I've found that this FIFO is under control of USB circuitry hence the USB Clock must be active when operating with such a memory as described here: community.silabs.com/.../70717
    However in most of my applications where I need RAM (stand alone projects) I don't have USB clock. Any wolkaround for this?

  • start the USB clock, that does not start USB. be aware that using the FIFO as RAM is slower than using the 'real' RAM. even better use a chip with sufficient 'real' ram there is a plethora of possibilities