beautypg.com

Write_flash – Zilog Z8F0130 User Manual

Page 263

background image

UM013037-1212

Zilog Functions

Zilog Developer Studio II – Z8 Encore!

User Manual

239

TDI

TDI (test and disable interrupts) is a Zilog intrinsic function that supports users creating
their own critical sections of code. It saves the previous interrupt status and disables inter-
rupts. The previous interrupt status is returned from TDI(). This function is intended to be
paired with a later call to RI(), which restores the previously existing interrupt status. See
the

RI

section on page 236 for a discussion of that function. The TDI function is an intrin-

sic function and is inline expanded.

Synopsis

#include

intrinsic unsigned char TDI(void);

Example

#include


void main(void)

{

unsigned char istat;

istat = TDI();/* Test and Disable Interrupts */

/* Do Something */

RI(istat);/* Restore Interrupts */

}

WRITE_FLASH

The WRITE_FLASH function is a Zilog function that writes a value to Flash memory at
the specified address.

Synopsis

#include

void reentrant WRITE_FLASH(rom const void *addr,char val);

Returns

If successful, the function returns zero; otherwise, it returns a nonzero value.

Example

#include

char x;

void main()

{

INIT_FLASH(_DEFFREQ); /* Target clock frequency */

WRITE_FLASH((rom const *)0x2f00,x); /* write to Flash */

x = READ_FLASH((rom const *)0x2f00); /* read from Flash */

}