On Sun, 17 Sep 2000, Damien Kee wrote: > ok, here are the bits of code relevant. > > It's all in c. Which C compiler? > In the interrupt handler: > { > write_flash2(1865, 'A'); > write_flash2(1866, 'B'); > write_flash2(1867, 'C'); > write_flash2(1868, 'D'); > write_flash2(1869, 'E'); > write_flash2(1870, 'F'); > > a = read_flash2(1865); > b = read_flash2(1866); > c = read_flash2(1867); > d = read_flash2(1868); > e = read_flash2(1869); > f = read_flash2(1870); > > send_char(a); > send_char(b); > send_char(c); > send_char(d); > send_char(e); > send_char(f); > } Looks OK to me so far... > send_char just sends the value through RS232 to hyperterminal. > > the actual functions are as below: > void write_flash2( int addr, char data ) ^^^^^^^^^ Umm, shouldn't this be long instead of int? I know at least with CCS and CC5X you need to use long or int16 if you're going to pass values greater than 255. > { > EEADRH = 0x00; > EEADR = 0x00; > EEDATA = 0x00; > EEDATH = 0x00; > //Write flash > EEADRH = addr / 256; > EEADR = addr % 256; > EEDATA = data; > > set_bit( EECON1, EEPGD); > set_bit( EECON1, WREN ); > EECON2 = 0x55; > EECON2 = 0xAA; > set_bit( EECON1, WR ); > asm nop; > asm nop; > clear_bit( EECON1, WREN ); > } > > char read_flash2(int addr ){ > EEADRH = 0x00; > EEADR = 0x00; > EEDATA = 0x00; > EEDATH = 0x00; > //Read flash > EEADRH = addr / 256; > EEADR = addr % 256; > set_bit( EECON1, EEPGD); > set_bit( EECON1, RD ); > asm nop; > asm nop; > data_rd = EEDATA; > send_char(EEDATA); > return data_rd; > } > > I'm doing the mod and divide functions, because I'd like to keep the > destination address as 1 integer. If there is a better way, I love to > know. > > thanks again. > > cheers > damo > > > > > Damien Kee > 3rd Year Electrical Engineering > University of Queensland > s369472@student.uq.edu.au > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > use mailto:listserv@mitvma.mit.edu?body=SET%20PICList%20DIGEST > > Dale --- The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny ..." -- Isaac Asimov -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! use mailto:listserv@mitvma.mit.edu?body=SET%20PICList%20DIGEST