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

No subject

why this is not working?

#include <stdio.h> // Standard I/O .h-file
#include <LPC23xx.H> // LPC2388 Header File

#define M32 (*(( volatile unsigned long *) (0x00070000)))

int fun(void);
int main(void)
{ int x;

PINSEL10 = 0; PINSEL4 = 0;

FIO2DIR = 0x0000000F; // P2.0..7 defined as Outputs

x = fun(); // Function call write and read

if(x == 0) { FIO2SET = 0x0000000F; }

FIO2SET = 0x00000000;

return 0;
}

int fun(void)
{ volatile unsigned long valu; unsigned int i;

unsigned long *ptr;

unsigned long flashaddress;

flashaddress = 0x00070000;

MAMCR = 0x00; MAMTIM = 0x03; MAMCR = 0x10;

M32 = 0x189; // data write ptr = (unsigned long *)flashaddress;

valu = *ptr;

if(valu == 0x189) return 0; // return 0 if data matches else return 1;
}

  • 1) "No subject"

    2) No description about what do happen, or what do not happen, or what YOU expected to happen.

    3) Incorrectly posted source code.

    4) Source code with a function given the descriptive name "fun". Short for function, or a funny function or what?

    5) Your funny function "fun" can return without returning a value, despite being declared to return int. Or is this a result of you failing to post the code as code?

    6) A variable with the descriptive name "valu" declared as volatile - where is the asynchronous updates of the variable?

    7) A main() that returns - but returns where? Do you think there is an OS that will give you a command line prompt after the program ends?

    8) You specify a pointer into flash memory - have you seen any documentation somewhere that M32 = 0x189 should result in a correct write into flash, and that such value should be immediately available for reading back? Have you looked at the documentation for how to update flash pages?