The Philippine Electronics and Technology Forum
February 10, 2012, 02:20:52 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: 1 [2]   Go Down
  Print  
Author Topic: Paano gamitin yung DATA LOGGING or internal memory ng Zilog Microcontroller  (Read 2353 times)
marcelino
Technical People
Solar Power Satellite
*****

Pogi/Ganda Points: 247
Offline Offline

Posts: 5861


...keep moving forward! - Robinson's


« Reply #20 on: October 02, 2009, 10:33:20 AM »

as far as i know wala talaga EEPROM ang Z8F64XX chips at yung 64K na memory sa 6421 ay yung flash yun, sinabi din ito ni sir paranz sa isang thread di ko lang matandaan kung aling thread, kaya mas malaki ang program ng encore compared sa pic dahil wala itong internal EEPROM sa PIC meron Grin


parang nabasa ko din yun...

parang ito yun: http://www.electronicslab.ph/forum/index.php?topic=11112.msg185801#msg185801

yeah... malalaki talga ang program memory ng zilog chips.
Logged

"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"
The Philippine Electronics and Technology Forum
« Reply #20 on: October 02, 2009, 10:33:20 AM »

 Logged
tiktak
Gas Turbine
**

Pogi/Ganda Points: 171
Offline Offline

Gender: Male
Posts: 2498



WWW
« Reply #21 on: October 02, 2009, 11:42:20 AM »

dyan ko nga din nabasa Cheesy sa XP naman may NVRAM pero di ko pa nagamit yun Grin
Logged

Bakit andaming hindi marunong gumamit ng search?Huh
ef - el - ay - pee
Lead Acid Battery
*******

Pogi/Ganda Points: 34
Offline Offline

Gender: Male
Posts: 680


Regrets, I have a few...


WWW
« Reply #22 on: October 02, 2009, 12:06:25 PM »

Try mo to. eto gamit ko nang kailangan kong mag write sa flash. based ito sa app note ng zilog. di ko kasi matest kung gumagana pa. wala akong slimboard.

FlashIO.c
Code:
#include <stdio.h>
#include <ez8.h>
#include "flash_IO.h"

#define PAGE_SIZE 512

char far Flash_Page[PAGE_SIZE]; // Far is used so this variable is placed in Edata
char near RamByte;

void init_flash(void) {
FPFH = 0x48;
FPFL = 0x00;
}

/* This function unlocks Flash for Flash Programming */

unsigned int UnlockFlash(unsigned int pagenum)
{
FCTL=0x00;
FPS=pagenum;
if( (FSTAT & 0x3F) == 0x00 ) // Flash Controller Locked state
{
FCTL = 0x73; // First unlock command

if ( (FSTAT & 0x3F) == 0x01 ) // First unlock Command recieved
{
FCTL = 0x8C; // Second unlock command

if ( (FSTAT & 0x3F) == 0x02 ) // Unlocked programming state
{
FPS=pagenum;
return 0x00;}
else
return 0xFF;
}
else
return 0xFF;

}
else
return 0xFF;

}

/* Locks the Flash controller */

void LockFlash(void)
{
while( (FSTAT & 0x3F) != 0x00 )
FCTL = 0x00; // write some value other than 0x73, 0x8c, 0x95, and 0x63
// to Flash control Register
}

/* This function Erases the page "pagenum" in Flash */

unsigned int EraseFlash(unsigned int pagenum)
{
unsigned int status;

status = UnlockFlash(pagenum);

if (status == 0x00)
{ // check if Flash is unlocked
//FPS = pagenum; // Set the page to be erased
FCTL = 0x95; // Page erase
LockFlash();
}

// No need to unlock as Flash controller locks immediatetly after page erase

return status;
}


/* This function writes a single byte value to the Flash location. It assumes the Page
   that corresponds to the location needs to be erased. */

void WriteByteToFlash(int location, unsigned int value)
{
unsigned int pagenum;
int i, TempLoc, counter=0;
char Interrupts;

pagenum = (location>>9); // compute the page number of byte address
TempLoc = (location & 0xFE00);

for(i=0; i< PAGE_SIZE; i++) // save the Flash page in RAM
Flash_Page[i] = ReadByteFromFlash(TempLoc+i);

// Modify the byte location in RAM that corresponds to Flash saved page
Flash_Page[location - TempLoc] = value;

EraseFlash(pagenum); // erase Flash Page

// Restore the page from RAM back to Flash
for(i=0; i< PAGE_SIZE; i++)
{
WriteByteToFlash1(TempLoc+i, Flash_Page[i]);
if(FSTAT==0x03) counter++;
}
LockFlash();

}

/* This function writes a single byte value in the Flash location. It assumes the Byte
   value of the Flash location is 0xFF and need NOT be erased before programming */

void WriteByteToFlash1(int location, unsigned int value)
{
UnlockFlash(location>>9);

// printf("FSTAT = %x, FPFH = %x, FPFL = %x\n", FSTAT, FPFH, FPFL);
// printf("location = %d, value = %2x\n", location, value);
RamByte=(location>>8);
asm("LD R8, _RamByte");

RamByte = (location & 0x00FF);
asm("LD R9, _RamByte");

RamByte = value;
asm("LD R10, _RamByte");

asm("LDC @RR8, R10"); // Load Byte into Flash location

}

/* This function returns a single byte value read from the Flash location */

unsigned int ReadByteFromFlash(int location)
{
unsigned int value;

RamByte=(location>>8);
asm("LD R8, _RamByte");

RamByte = (location & 0x00FF);
asm("LD R9, _RamByte");

asm("LDC R10, @RR8");
asm("LD _RamByte, R10");
value = RamByte;

return (value&0xFF);
}

FlashIO.h
Code:
/*************************************************
 *  Copyright (C) 1999-2002 by  ZiLOG, Inc.
 *  All Rights Reserved
 *
 * Flash_IO.h : Header file for Flash Driver
 **************************************************/

//Prototype definitions

void init_flash(void);
unsigned int UnlockFlash(unsigned int pagenum);
void LockFlash(void);
unsigned int EraseFlash(unsigned int pagenum);

void WriteByteToFlash(int location, unsigned int value);
void WriteByteToFlash1(int location, unsigned int value);
unsigned int ReadByteFromFlash(int location);

Logged

"Engineers are the Oompah-Loompahs of Science" - Dr. Sheldon Lee Cooper
The Philippine Electronics and Technology Forum
   

 Logged
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
zilog encore XP ADC and data logging.. « 1 2 »
Zilog Microcontrollers
beginner wan 37 6683 Last post January 29, 2008, 02:03:23 PM
by microlan2008
Collaborative Project Proposal: Remote Data logging system for PHIVOLCS/PAG-ASA « 1 2 3 4 5 »
Personal, Academic and Commercial Electronics Projects
creedcradle 82 10081 Last post July 12, 2008, 11:29:55 AM
by shadowmandxbb
paano po gamitin ang occilloscopes
ECE Students
jem2 7 1088 Last post February 18, 2009, 01:16:16 PM
by danny
Arc Welding m/c ,pwede ba gamitin yung normal wall outlet?
Electrical Circuits and Devices
threx 5 1310 Last post October 23, 2009, 05:51:32 PM
by threx
Wireless BP monitoring with data logging
Thesis and Project Proposal
downloaderer 0 79 Last post July 07, 2011, 10:00:17 PM
by downloaderer
Zigbee+Ethernet Shield = dual data logging posible kaya???
Thesis and Project Proposal
downloaderer 2 73 Last post July 10, 2011, 06:49:55 PM
by downloaderer
Adding Android Internal memory
Cellular Phones and Accessories
Positron E+ 9 240 Last post January 22, 2012, 02:13:19 PM
by iaera6
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!