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

msc1200_adc on hardware

The example program msc1200_adc works in the simulator, but does not appear to run on the msc1200evm hardware.
If the Ouput -> Run User Program box is checked and the name of the download is corrected to match the name of the executable, the program downloads and starts to run, but the characters in the terminal window are gibberish.
The code appears to use 2400 & 8bits, but setting the terminal to these values does not fix it.
Does this example work on the real hardware or just the simulator?

  • Does this example work on the real hardware or just the simulator

    When you select the abnormal model "large" you will, usually, have to modify everything associated with timing because nobody anticipated you would do that.

    Erik

  • I was using small memory model when attempting to run on the hardware, so I dont see how "large" becomes an issue. I'd like to see it run in the large model, but have not attempted that since it does not work in the small model

  • Well, in your other post you state thet you use the large model.

    Erik

    PS WHY???

  • does e.g. "blinky" work ??

    Erik

  • I will need a large model for my application. I want to capture ~10K of data from the ADC and process it so I need a bigger chunk of memory.

  • I've tried to run blinky but I dont see anything. This might be due to differences between the TI board and the MCBx51(?).

    The hardware appears to be working. I modified my original program to blink the lights successfully:
    =============
    #include <REG1200.H>
    #include <stdio.h>

    extern void autobaud(void);

    sbit RedLed = P3^4;
    sbit YelLed = P3^5;

    void wait (void) { /* wait function */
    ; /* only to delay for LED flashes */
    }

    void main(void) {
    unsigned int i; /* Delay var */
    unsigned char j; /* LED var */

    for (j=0x01; j< 30; j++)
    {
    RedLed = ! RedLed;
    for (i = 0; i < 10000; i++)
    { /* Delay for 10000 Counts */
    wait(); /* call wait function */
    }

    }

    CKCON = 0x10; // per MSC1200 data sheet
    TCON = 0; // per MSC1200 data sheet
    autobaud();
    printf("Hello\n");
    }
    ===================

  • I will need a large model for my application. I want to capture ~10K of data from the ADC and process it so I need a bigger chunk of memory.

    No, you will not.

    Using the large model slow everything down. Use the small model and declare your ADC data array as xdata.

    Erik

  • This (smal and xdata) is actually the first thing I tried. I have retried it with a simpler case and it works.

    It appears that there is something a bit tricky about accessing xdata arrays that I need to investigate further.
    unsigned int xdata d[100];
    d[99] = 99;
    printf("d[99] = %d\n"); // does not get 99

    Thanks for your help.

  • i do not use printf (what is the purpose?), but should
    printf("d[99] = %d\n"); // does not get 99
    not be
    printf("d[99] = %d[99]\n"); // get 99

    Erik

  • that was a typo - it should have been
    > printf("d[99] = %d\n", d[99] );
    I have found the original problem that made me think i needed a LARGE model (now I think it is either a compiler issue or my understanding of xdata needs adjustment.)
    The following fails for xdata but works as expected if xdata is removed in the dd[] declaration.
    ============
    int i;
    int xdata dd[10];
    ... // uart init stuff

    i = 8;
    dd[8] = i;
    printf("dd[8] = %d\n", dd[8]); // works = '8'
    printf("dd[i] = %d\n", i, dd[i]); // works = '8'

    i = 8;
    dd[i] = i;
    printf("dd[8] = %d\n", dd[8]); // fails = '-1'
    ================

    Does the array index 'i' need something special for the assignment "dd[i] = i" to work when using xdata?

  • "Does the array index 'i' need something special for the assignment "dd[i] = i" to work when using xdata?"

    No, you don't need to do anything special with i. It should Just Work (Tm).

    Have you configured the start address and size of your xdata area in the project options?

  • Under the target tab on the "Options for Target" window I've set the "Off chip xdata memory"
    Ram Start: 0x0000
    Ram Size : 0x4000

    I'm just getting familiar with Keil tools so I may have something else misconfigured.

  • I'm not familiar with your derivative, but some have SFR bits that control what physical memory space is mapped into the xdata addressing range.

    Could this be your problem?

  • I'll look at the SFR as you suggest, but I've found a curious result that makes me suspect the compiler has issues with xdata arrays. The following prints '8' in both printf statements as expected.
    ===========
    works
    ===========
    int xdata dd[10];
    i = 8;
    z = dd[8] = i;
    printf("dd[8] = %d\n", dd[8]);
    printf("z = %d\n", z);
    ===========

    but the following prints '-1' in both print statements. This should be equivalent to the preceding code snippet (right?).
    ===========
    fails
    ===========
    int xdata dd[10];
    i = 8;
    dd[8] = i;
    z = dd[8]; // <=== hmmm?
    printf("dd[8] = %d\n", dd[8]);
    printf("z = %d\n", z);
    ===========

  • I'll look at the SFR as you suggest
    I do not know your derivative, but all I know need some bit (re)set in a SFR to access internal XRAM.

    but the following prints '-1' in both print statements. This should be equivalent to the preceding code snippet (right?).
    printing ff usually means that the hardware does not read the external memory.

    Erik