Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Zilog comparator programming for battery and supercap

Status
Not open for further replies.

kct

Newbie level 1
Joined
Apr 15, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
Good day to everyone.

Currently I'm in the process of using a Zilog MCU (Z8F042A) to design a voltage comparator for comparing a voltage between a mobile phone battery with a maximum voltage of 4.2V, and a supercapacitor(s) rated at 5V. At any instant the supercapacitor's voltage is equivalent to that of the battery, the system will send a voltage to the gate of a P channel MOSFET to switch the MOSFET off. The moment the supercapacitor's voltage falls below that of the battery, the MOSFET is to be switched on again.

The problem now is, I am not so sure about programming the Zilog itself (programming has never been my strong point), not to mention the issue of whether I need to use the ADC or not. It would be great if anyone can help me out.

Code:
#include<eZ8.h>
#include <stdio.h>
#include <sio.h>
#include <adc.h>

unsigned int VINSUP; // Voltage from Supercapacitor
unsigned int VINREF; // Voltage from Battery

void main(void)
{
	ADCCTL0 = 0xAE; // Conversion Enabled
					// Reference Buffer Disabled
					// Continuous Mode

	ADCCTL1 = 0x01; //Single Ended Buffered Input with Unity Gain

	PCDD = 0xF7; // PC3 as output and others as input
	
	PCOUT = 0xFF; // Turn off all ports

	while(1)
	{
		if ((PCIN & 0x01) == 0) // To check if PC0 is low or not
		{
			PCOUT = 0xF7;
		}
		else
		{
			PCOUT = 0xFF;
		}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top