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

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

Pages: 1 ... 6 7 [8]   Go Down
  Print  
Author Topic: Request Zilog Encore! Microcontroller codes here (C Only)  (Read 12670 times)
anemokid
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 6


« Reply #140 on: February 12, 2011, 10:35:02 PM »

Naku! pasensya na po.. hehe...
eto na po.. inirepost ko para madali basahin..

Hello po.  Smiley
Pwede po bang patulong sa code?
Gagamit po kami ng sim900d gsm modem at z8 encore.
Eto po yung mga requirements:
1. Display 3 or more messages with 160 characters each.
2. The message sent can only be displayed if the syntax is right (e.g. DISPLAY <MESSAGE>)
3. The gsm modem will send a reply as a confirmation whether the message was successfully displayed or not.
4. The current time is displayed at the end of each message.

Thanks po in advance.  Cheesy Cheesy
Logged
The Philippine Electronics and Technology Forum
« Reply #140 on: February 12, 2011, 10:35:02 PM »

 Logged
anemokid
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 6


« Reply #141 on: February 12, 2011, 10:37:03 PM »

naku! pasensya na po...
hehe.. eto po.. nirepost ko po para mas madali mabasa...

Hello po.  Smiley
Pwede po bang patulong sa code?
Gagamit po kami ng sim900d gsm modem at z8 encore.
Eto po yung mga requirements:
1. Display 3 or more messages with 160 characters each.
2. The message sent can only be displayed if the syntax is right (e.g. DISPLAY <MESSAGE>)
3. The gsm modem will send a reply as a confirmation whether the message was successfully displayed or not.
4. The current time is displayed at the end of each message.

Thanks po in advance.  Cheesy Cheesy
Logged
anemokid
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 6


« Reply #142 on: February 12, 2011, 10:43:22 PM »

Boss Asimo..  Smiley
salamat po sa pagreply..

sa 8x8 led matrix na board madidisplay yung message...
160 po yung minimum... pwede naman po mas mataas..mas ok nga po yung eh..  Smiley
Logged
paranz
Moderator
Nuclear Reactor
*****

Pogi/Ganda Points: 167
Offline Offline

Gender: Male
Posts: 4511


1/4W resistor specialist


« Reply #143 on: February 14, 2011, 01:08:01 PM »

Here is a keypad code for zilog.

Tested on a 40DIP zilog encore chip. Keypad connection is PORTB. 4 ROW pins to PORTB<3:0> and 4 COLUMN pins to PORTB<7:0>.

You can use either 4x3 or 4x4 keypad. Simply comment out the macro USE_4X4_KEYPAD in keypad_sm.c if using a 4x3 keypad.

The keypad read/scan function is performed by KeypadTask() and it is implemented as a state machine to eliminate blocking.

KeypadTask() state machine runs every 5 milliseconds and it is controlled by a skip timer variable driven by a timer interrupt (i.e. Timer0).


keypad.h

Code:

//Franz Duran - 7/30/2010 v1.0


#include <ez8.h>
#include "keypad_sm.h"

/* Edit the 7 macros below to match your application.*/

#define USE_4X4_KEYPAD TRUE //Uncomment if using 4x3 keypad.
#define KEYPAD_ROW PBOUT
#define KEYPAD_COL PBIN
#define KEYPAD_DD PBDD
#define KEYPAD_AF PBAF
#define KEYPAD_HDE PBHDE
#define KEYPAD_OC PBOC

//----------------(DON'T EDIT/MODIFY BELOW THIS LINE)--------------------

//Misc macro
#define KEYPAD_ROW_MASK 0x0F //ROW mask for PORTx<3:0> pins.
#ifdef USE_4X4_KEYPAD
#define KEYPAD_COLUMN_MASK 0xF0 //Column mask for PORTx<7:4> pins.
#else
#define KEYPAD_COLUMN_MASK 0x70 //Column mask for PORTx<6:4> pins.  
#endif

#define NUM_ROW 4 //Number of rows in keypad.
#define ERROR 0xFF
#define OK 0x00

//------------------------------------------------------------------------

//4x4 keypad
#ifdef USE_4X4_KEYPAD
#define KEY1 0xE0 //ROW0 key bit patterns
#define KEY2 0xD0
#define KEY3 0xB0
#define KEYA 0x70
#define KEY4 0xE1 //ROW1 key bit patterns
#define KEY5 0xD1
#define KEY6 0xB1
#define KEYB 0x71
#define KEY7 0xE2 //ROW2 key bit patterns
#define KEY8 0xD2
#define KEY9 0xB2
#define KEYC 0x72
#define KEYSTAR 0xE3 //ROW3 key bit patterns
#define KEY0 0xD3
#define KEYHASH 0xB3
#define KEYD 0x73
#else
//4x3 keypad
#define KEY1 0x60 //ROW0 key bit patterns
#define KEY2 0x50
#define KEY3 0x30
#define KEY4 0x61 //ROW1 key bit patterns
#define KEY5 0x51
#define KEY6 0x31
#define KEY7 0x62 //ROW2 key bit patterns
#define KEY8 0x52
#define KEY9 0x32
#define KEYSTAR 0x63 //ROW3 key bit patterns
#define KEY0 0x53
#define KEYHASH 0x33
#endif

//------------------------------------------------------------------------

//Global variables (module/file scope)
static unsigned char _key_ascii=0x00; //Pressed key in ascii
static unsigned char _key_ready; //new key flag

//Global variables (application-wide scope)
volatile unsigned char keypad_skptmr; //Skip timer; controlled by ISR
unsigned char keypad_statevar; //keypad state machine state variable

//------------------------------------------------------------------------

//Function Prototypes (local functions)
static unsigned char _KeypadGetKeyAscii(unsigned char key_bit_pattern);
static unsigned char _KeypadScan(void);
static unsigned char _KeypadIsKeyReady(void);
static unsigned char _KeypadSetKey(unsigned char keyAscii);
static void _KeypadClearKey(void);

//------------------------------------------------------------------------

//Check if any key is pressed.
static unsigned char _KeypadIsKeyPress(void)
{
unsigned char i;
unsigned char key_port=0x00;

KEYPAD_ROW &= ~KEYPAD_ROW_MASK; //All ROWs are logic low.

for(i=0;i<125;i++) //short delay approx 100us.
continue;

//If any columns are low, then a keypress is detected.
key_port = KEYPAD_COL & KEYPAD_COLUMN_MASK;
if ( key_port != KEYPAD_COLUMN_MASK )
return TRUE;
else
return FALSE;
}

//------------------------------------------------------------------------

//Convert key bit pattern to corresponding ASCII character.
static unsigned char _KeypadGetKeyAscii(unsigned char key_bit_pattern)
{
switch(key_bit_pattern)
{
case KEY1: return '1';
case KEY2: return '2';
case KEY3: return '3';
case KEY4: return '4';
case KEY5: return '5';
case KEY6: return '6';
case KEY7: return '7';
case KEY8: return '8';
case KEY9: return '9';
case KEYSTAR: return '*';
case KEY0: return '0';
case KEYHASH: return '#';
#ifdef USE_4X4_KEYPAD
case KEYC: return 'C';
case KEYA: return 'A';
case KEYB: return 'B';
case KEYD: return 'D';
#endif
}
return NULL;
}


//------------------------------------------------------------------------

//Keypad scanning routine.
static unsigned char _KeypadScan(void)
{
unsigned char i;
unsigned char column_bits = 0x00;
unsigned char current_row = 0;

//Scan rows sequentially, from ROW0 to ROW3, and check if
// one COLUMN pin is cleared.
for(current_row=0;current_row<NUM_ROW;current_row++)
{
KEYPAD_ROW = ~(0x01 << current_row);

for(i=0;i<125;i++) //Short delay approx 100us.
continue;

column_bits = KEYPAD_COL & KEYPAD_COLUMN_MASK;
if(column_bits!=KEYPAD_COLUMN_MASK)
{
return (column_bits | current_row);
}
}
return NULL; //No key detected.
}

//------------------------------------------------------------------------

//Set the key ready flag.
//This function is called from within the KeypadTask().
static unsigned char _KeypadSetKey(unsigned char keyAscii)
{
if(_key_ready) //If already set, don't overwrite
{
return ERROR; // previous character so return ERROR.
}
else
{
_key_ascii = keyAscii;
_key_ready = TRUE;
return OK; //Done.
}
}

//------------------------------------------------------------------------

//Clear the key ready flag.
static void _KeypadClearKey(void)
{
_key_ready = FALSE;
}

//------------------------------------------------------------------------

//Test if there is a new key.
static unsigned char _KeypadIsKeyReady(void)
{
return _key_ready;
}

//------------------------------------------------------------------------

//Retrieve the value of pressed key (in ASCII).
unsigned char KeypadGetKey(void)
{
if(_KeypadIsKeyReady())
{
_KeypadClearKey();
return _key_ascii;
}
else
{
return NULL;
}
}

//------------------------------------------------------------------------

//States
char enum{
KEY_WAIT_4PRESS,
KEY_SCAN1,
KEY_DEBOUNCE_DELAY,
KEY_SCAN2,
KEY_SET_NEW,
KEY_WAIT_4RELEASE
};


//Keypad task implemented as a state machine.
//This task is executed every 5 millisecond. Completes in 50 ms.
void KeypadTask(void)
{
static unsigned char key_ascii=0x00;
static unsigned char key_bit_pttrn1=0x00;
static unsigned char key_bit_pttrn2=0x00;
static unsigned char key_debounce_skptmr=0;

//If timer elapsed, run state machine below.
if(keypad_skptmr==0)
{
keypad_skptmr = 5; //5 millisecond delay.
}
else
return;

//Keypad state machine.
switch(keypad_statevar)
{
//Wait until a key press is detected.
case KEY_WAIT_4PRESS:
if(_KeypadIsKeyPress())
{
keypad_statevar = KEY_SCAN1;
}
break;

//Scan keypad.
case KEY_SCAN1:
key_bit_pttrn1 = _KeypadScan();
if(key_bit_pttrn1)
{
keypad_statevar = KEY_DEBOUNCE_DELAY;
key_debounce_skptmr = 5;
}
else
keypad_statevar = KEY_WAIT_4PRESS;
break;

//Execute time delay to debounce (25ms)
case KEY_DEBOUNCE_DELAY:
if(--key_debounce_skptmr==0)
{
keypad_statevar = KEY_SCAN2;
}
break;

//Scan again and compare.
case KEY_SCAN2:
key_bit_pttrn2 = _KeypadScan();
if(key_bit_pttrn1 == key_bit_pttrn2)
{
key_ascii = _KeypadGetKeyAscii(key_bit_pttrn1);
keypad_statevar = KEY_SET_NEW;
}
else
{
keypad_statevar = KEY_WAIT_4PRESS;
}
break;

//Set new key.
case KEY_SET_NEW:
if(_KeypadSetKey(key_ascii)==OK)
{
keypad_statevar = KEY_WAIT_4RELEASE;
}
break;

//Wait until key is released.
case KEY_WAIT_4RELEASE:
if(_KeypadIsKeyPress()==FALSE)
{
keypad_statevar = KEY_WAIT_4PRESS;
}
break;

//Error! Restart state machine.
default:
keypad_statevar = KEY_WAIT_4PRESS;
break;
}
return;
}


//------------------------------------------------------------------------

//Initialize keypad pins.
void KeypadInit(void)
{
_key_ready = FALSE;
keypad_statevar = KEY_WAIT_4PRESS;
keypad_skptmr = 5;

KEYPAD_DD = KEYPAD_COLUMN_MASK;
KEYPAD_AF &= ~0xFF;
KEYPAD_OC &= ~KEYPAD_ROW_MASK;
KEYPAD_HDE &= ~KEYPAD_ROW_MASK;
KEYPAD_ROW &= ~KEYPAD_ROW_MASK; //All ROWs intially cleared.
return;
}



keypad_sm.h

Code:

#ifndef _KEYPAD_SM_H_
#define _KEYPAD_SM_H_

//Misc macro
#define TRUE 1
#define FALSE 0
#define NULL 0x00

//Function Prototypes.
void KeypadTask(void); /* Keypad Task */
void KeypadInit(void); /* Intialize keypad pins */
unsigned char KeypadGetKey(void); /* Retrieve key (in ASCII) */

#endif //_KEYPAD_SM_H_

Logged
paranz
Moderator
Nuclear Reactor
*****

Pogi/Ganda Points: 167
Offline Offline

Gender: Male
Posts: 4511


1/4W resistor specialist


« Reply #144 on: February 14, 2011, 01:10:22 PM »

Here is an example application for the keypad code. Press the keypad to turn on LEDs.
Example: If '7' key is pressed, the 4 LEDs will display binary 7.

main.c

Code:
// HARDWARE:
// - Z8F6421, 18.432 MHz Crystal oscillator
// - 4x4 Keypad --> PORTB
// - ROW<3:0>--> PORTB<3:0>
// - COLUMN<3:0> --> PORTB<7:4>
// - 4 LEDs --> PORTA<3:0>

#include <ez8.h>
#include "tmr0.h"
#include "keypad_sm.h"

#define LED_PORT PAOUT

//----------------------------------------------------------------------
//Function Prototypes

void SystemInit(void);
void LEDInit(void);
void DoLEDDisplayTask(void);

//----------------------------------------------------------------------

void main(void)
{
SystemInit();

while(1)
{
KeypadTask();
DoLEDDisplayTask();
/*
Add your codes here...
*/
}
}

//----------------------------------------------------------------------

void SystemInit(void)
{
TMR0Init();
LEDInit();
KeypadInit();

return;
}

//----------------------------------------------------------------------

void LEDInit(void)
{
PADD &= ~0x0F; //4 LEDs
PAAF &= ~0x0F;
PAOC &= ~0x0F;
PAHDE |= 0x0F;
LED_PORT &= ~0x0F;
return;
}

//------------------------------------------------------------------------

void DoLEDDisplayTask(void)
{
unsigned char key_ascii;

//Get key.
key_ascii = KeypadGetKey();

//If no key, exit immediately from this function.
if(!key_ascii)
return;

if(key_ascii == '1')
LED_PORT = 0x01;
else if (key_ascii == '2')
LED_PORT = 0x02;
else if (key_ascii == '3')
LED_PORT = 0x03;
else if (key_ascii == '4')
LED_PORT = 0x04;
else if (key_ascii == '5')
LED_PORT = 0x05;
else if (key_ascii == '6')
LED_PORT = 0x06;
else if (key_ascii == '7')
LED_PORT = 0x07;
else if (key_ascii == '8')
LED_PORT = 0x08;
else if (key_ascii == '9')
LED_PORT = 0x09;
else if (key_ascii == '0')
LED_PORT = 0x00;
else if (key_ascii == '*')
LED_PORT = 0x0F;
else if (key_ascii == '#')
LED_PORT ^= 0x0F;
else if (key_ascii == 'A')
LED_PORT ^= 0x0F;
else if (key_ascii == 'B')
LED_PORT ^= 0x0F;
else if (key_ascii == 'C')
LED_PORT ^= 0x0F;
else if (key_ascii == 'D')
LED_PORT ^= 0x0F;

return;
}
Logged
paranz
Moderator
Nuclear Reactor
*****

Pogi/Ganda Points: 167
Offline Offline

Gender: Male
Posts: 4511


1/4W resistor specialist


« Reply #145 on: February 14, 2011, 01:26:08 PM »

here is the Timer0 code also. The Timer0 interrupt decrements the keypad_skptmr variable.


tmr0.c

Code:
#include <ez8.h>
#include "tmr0.h"

//----------------------------------------------------------------------
extern unsigned char keypad_skptmr; //declared in keypad_sm.c


//----------------------------------------------------------------------

//Interrupt service routine for TMR0
#pragma interrupt
void isr_tmr0(void)
{
DI();
if (skptmr0_1)
--skptmr0_1;
if (skptmr0_2)
--skptmr0_2;
if (keypad_skptmr)
--keypad_skptmr;
IRQ0 &= ~0x20;
EI();
}

//----------------------------------------------------------------------

void TMR0Init(void)
{
skptmr0_1 = 250;
skptmr0_2 = 100;

DI(); //Disable global interrupt
T0CTL1 = 0x00;
T0CTL1 &= ~TEN_TIMER0; //Disable Timer 0
T0CTL1 |= PRES_TIMER0 | TMODE_TIMER0; //Prescaler assignment, continuous mode

T0H = 0x00;
T0L = 0x01;

T0RH = (unsigned char) (RELOAD_TIMER0 >> 8); //RELOAD value loaded
T0RL = (unsigned char) (RELOAD_TIMER0 & ~0xFF00);

SET_VECTOR(TIMER0, isr_tmr0); //when TIMER0 interrupt occurs, tell
//CPU to execute the isr_tmr0 ISR

IRQ0ENH |= 0x20; //Enable Timer 0 interrupt with
IRQ0ENL |= 0x20; //LEVEL 3 priority

IRQ0 &= ~0x20; //Clear previous/pending TIMER0 int
T0CTL1 |= TEN_TIMER0; //Enable Timer0
EI(); //Enable global interrupt.

return;
}




tmr0.h

Code:

#ifndef _TMR0_H_
#define _TMR0_H_


//Edit the 3 macros below to match your application requirements.
#define TMR0_INT_FREQ 1000L /* Timer0 Interrupt Frequency*/
#define TMR0_PRESCALER 32 /* Prescaler rate = 1,2,4,8,16,32,64,128*/
#define SYSTEM_CLOCK 18432000L /* Crystal Oscillator = 18.432MHz*/

//Misc Macros
#define TEN_TIMER0 0x80
#define TPOL_TIMER0 0x40

#if (TMR0_PRESCALER == 1)
 #define PRES_TIMER0 0x00
#elif (TMR0_PRESCALER == 2)
 #define PRES_TIMER0 0x08
#elif (TMR0_PRESCALER == 4)
 #define PRES_TIMER0 0x10
#elif (TMR0_PRESCALER == 8)
 #define PRES_TIMER0 0x18
#elif (TMR0_PRESCALER == 16)
 #define PRES_TIMER0 0x20
#elif (TMR0_PRESCALER == 32)
 #define PRES_TIMER0 0x28
#elif (TMR0_PRESCALER == 64)
 #define PRES_TIMER0 0x30
#elif (TMR0_PRESCALER == 128)
 #define PRES_TIMER0 0x38
#else
#error  Hoy bobo, maling prescaler ang ginamit mo!
#endif

#define TMODE_TIMER0 0x01 //Timer mode = CONT.
#define RELOAD_TIMER0 (SYSTEM_CLOCK/(TMR0_INT_FREQ*TMR0_PRESCALER))

//----------------------------------------------------------------------
//Function Prototypes
void TMR0Init(void);


#endif //_TMR0_H_

Logged
anemokid
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 6


« Reply #146 on: February 14, 2011, 05:17:23 PM »

Sir Paranz! Good day po..  Smiley

sms base po yung samin kaya po hindi na po kami gagamit ng keypad...
Meron na po kaming sample code kaya lang po...kulang kami ng header file na myuart.h, functions.h, at GSM.h
...
Pwede nyo po ba icheck yung code namin?? isesend nalang po namin sa inyo... Smiley

Thanks po!!! Smiley
Logged
marsianpipz
Size C Battery
*****

Pogi/Ganda Points: 9
Offline Offline

Gender: Male
Posts: 237


life is so amazing :D


« Reply #147 on: February 17, 2011, 09:48:05 AM »

salamt po sa keypad Cheesy
Logged

"   Life doesn't get easier, you just get stronger.              "
grimwald
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 8


« Reply #148 on: March 08, 2011, 03:04:13 AM »

mga sir/mam pki check naman po ung code na i2 pra po sa on/off kung tama..gamit po namen ay sim900d at zilog irc slimboard..(PA4 is connected to TX,PA5 is connected to RX,PA3 is connected to PowerON) for On/Off po sya ng appliances
Code:
#include <eZ8.h>
#include <sio.h>

extern unsigned char *rxptr;
extern near unsigned char rxlen; // lenght of SIO received string
extern unsigned char Rx[250];
extern near unsigned char rxtmr;
extern unsigned char PCbuff;

char RING;

#pragma interrupt
void isr_uart0_rx(void)
{
unsigned char rxin;
rxin=U0RXD; // read SIO
if(rxlen>=250) return; // buffer overflow, no further rx
*rxptr=rxin; // store in buffer
rxlen++;
rxptr++; // point to next
}

//////////////////////////////////////////////////////////
//Intialize Uart-0
void init_uart0(void)
{
    init_uart(_UART0,_DEFFREQ,38400); // Setup Uart0
SET_VECTOR(UART0_RX, isr_uart0_rx);  // Define interrupt routine
IRQ0ENH |= 0x10; // Set Interrupt Priority High
IRQ0ENL |= 0x10; // Set Interrupt Priority High
}

void send(char c)
{
        /* UART0 */
        while (!(U0STAT0 & 0x04));  // Transmit Data register enabled
        U0TXD = c;                  // Send data
}

//////////////////////////////////////////////////////////
// Transmit string
// and wait till response is complete
void Tx_String(char *sptr)
{
for(;*sptr;++sptr){
if(*sptr == 0x0A)
send(0x0D);
else
    send(*sptr);
}
}

void WaitRX(void)
{
rxptr = Rx;
rxlen=0;
rxtmr = 45;
while(rxtmr > 0){}
// while((Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')) && rxtmr>0){}
}

void WaitRX2(void)
{
rxptr = Rx;
rxlen=0;
rxtmr = 1000;
while((Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')) && (rxtmr>0)){}
// while(Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')){}
}
Main.c
Code:
#include <eZ8.h>
#include <sio.h>

extern unsigned char *rxptr;
extern near unsigned char rxlen; // lenght of SIO received string
extern unsigned char Rx[250];
extern near unsigned char rxtmr;
extern unsigned char PCbuff;

char RING;

#pragma interrupt
void isr_uart0_rx(void)
{
unsigned char rxin;
rxin=U0RXD; // read SIO
if(rxlen>=250) return; // buffer overflow, no further rx
*rxptr=rxin; // store in buffer
rxlen++;
rxptr++; // point to next
}

//////////////////////////////////////////////////////////
//Intialize Uart-0
void init_uart0(void)
{
    init_uart(_UART0,_DEFFREQ,38400); // Setup Uart0
SET_VECTOR(UART0_RX, isr_uart0_rx);  // Define interrupt routine
IRQ0ENH |= 0x10; // Set Interrupt Priority High
IRQ0ENL |= 0x10; // Set Interrupt Priority High
}

void send(char c)
{
        /* UART0 */
        while (!(U0STAT0 & 0x04));  // Transmit Data register enabled
        U0TXD = c;                  // Send data
}

//////////////////////////////////////////////////////////
// Transmit string
// and wait till response is complete
void Tx_String(char *sptr)
{
for(;*sptr;++sptr){
if(*sptr == 0x0A)
send(0x0D);
else
    send(*sptr);
}
}

void WaitRX(void)
{
rxptr = Rx;
rxlen=0;
rxtmr = 45;
while(rxtmr > 0){}
// while((Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')) && rxtmr>0){}
}

void WaitRX2(void)
{
rxptr = Rx;
rxlen=0;
rxtmr = 1000;
while((Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')) && (rxtmr>0)){}
// while(Rx[rxlen-1] != 0x0A || (Rx[rxlen-3] != 'K' && Rx[rxlen-3] != 'R')){}
}
myuart.c
Logged
matronell
Size C Battery
*****

Pogi/Ganda Points: 14
Offline Offline

Posts: 173


« Reply #149 on: August 19, 2011, 02:33:52 PM »

Request code for dot matrix display using 3 matrix board from e-gizmo.

Laging dalawa lang napapagana ko please help Sad thanks po
Logged
ΔЅịMø
Diesel Generator
*

Pogi/Ganda Points: 81
Offline Offline

Gender: Male
Posts: 1661


"Live Curious"


« Reply #150 on: August 20, 2011, 09:46:34 AM »

post your code...
Logged

by giving people the power to share, we're making the world more transparent.
matronell
Size C Battery
*****

Pogi/Ganda Points: 14
Offline Offline

Posts: 173


« Reply #151 on: August 20, 2011, 02:12:23 PM »

Quote
#include <ez8.h>
#include "cmap.h"
#include <sio.h>
//#include "SCANCODE.h"

void load_char(char ch);
void clock(void);
void strobe(void);
void isr_timer0(void);
void Display(void);
void REFRESH(void);
void shift(void);
unsigned int i;

int d;
float delay;

//PB0 = Strobe
//PB1 = Data
//PB2 = Clock
   
unsigned char KBdata,KBtemp,KBcntr,KBmask =0;
unsigned char char_pointer;
char Display_Ram[69];
char status = 0;
unsigned char mask;
const char LED_DATA[]="TEST__________________         ";     
char endchar = 0x13;
char PB;
char count;   
unsigned char shift_counter;

void load(void)
{
   char counter1;
   if(LED_DATA[char_pointer+1] == 0x13)
   char_pointer = 0;
    for(counter1 = 0; counter1 < 5; counter1++)
   {
      Display_Ram[63 + counter1] = character_data[(LED_DATA[char_pointer] - 0x20)][counter1];
   }   
   Display_Ram[68] = 00;   
   char_pointer++;
}

void Clear_Display_Ram(void)
{
   unsigned char rcount;
   for(rcount=0;rcount<68;rcount++)
      Display_Ram[rcount] = 0xff;
}

void scan(void)
{
   for (count=64;count>(-1);count--)
   {
      if ((Display_Ram[count] & mask) == mask)
      {
         PBOUT |= 0x02;
      }
      else
      {
         PBOUT &= ~0x02;
      }
      clock();
   }
   strobe();
}

#define INTEN 100

void main()
{
   PADD = 0xff;
   PBDD &= ~0x07;
   PCDD = 0x00;

   PBOUT = 0xff;   
   PCOUT = 0xff;

//   init_uart(_UART0,  _DEFFREQ, _DEFBAUD);
//   select_port(_UART0);


   for(d=0;d<64;d++)
   {
      clock();
   }
      strobe();
      d = 0;

   while(1)
   {
      Display();
      i++;
      if(i == 2){
      i = 0;
      shift();}
   }

}      

void shift(void)
{
   Display_Ram[0] = Display_Ram[1];
   Display_Ram[1] = Display_Ram[2];
   Display_Ram[2] = Display_Ram[3];
   Display_Ram[3] = Display_Ram[4];
   Display_Ram[4] = Display_Ram[5];
   Display_Ram[5] = Display_Ram[6];
   Display_Ram[6] = Display_Ram[7];
   Display_Ram[7] = Display_Ram[8];
   Display_Ram[8] = Display_Ram[9];
   Display_Ram[9] = Display_Ram[10];
   Display_Ram[10] = Display_Ram[11];
   Display_Ram[11] = Display_Ram[12];
   Display_Ram[12] = Display_Ram[13];
   Display_Ram[13] = Display_Ram[14];
   Display_Ram[14] = Display_Ram[15];
   Display_Ram[15] = Display_Ram[16];
   Display_Ram[16] = Display_Ram[17];
   Display_Ram[17] = Display_Ram[18];
   Display_Ram[18] = Display_Ram[19];
   Display_Ram[19] = Display_Ram[20];
   Display_Ram[20] = Display_Ram[21];
   Display_Ram[21] = Display_Ram[22];
   Display_Ram[22] = Display_Ram[23];
   Display_Ram[23] = Display_Ram[24];
   Display_Ram[24] = Display_Ram[25];
   Display_Ram[25] = Display_Ram[26];
   Display_Ram[26] = Display_Ram[27];
   Display_Ram[27] = Display_Ram[28];
   Display_Ram[28] = Display_Ram[29];
   Display_Ram[29] = Display_Ram[30];
   Display_Ram[30] = Display_Ram[31];
   Display_Ram[31] = Display_Ram[32];
   Display_Ram[32] = Display_Ram[33];
   Display_Ram[33] = Display_Ram[34];
   Display_Ram[34] = Display_Ram[35];
   Display_Ram[35] = Display_Ram[36];
   Display_Ram[36] = Display_Ram[37];
   Display_Ram[37] = Display_Ram[38];
   Display_Ram[38] = Display_Ram[39];
   Display_Ram[39] = Display_Ram[40];
   Display_Ram[40] = Display_Ram[41];
   Display_Ram[41] = Display_Ram[42];
   Display_Ram[42] = Display_Ram[43];
   Display_Ram[43] = Display_Ram[44];
   Display_Ram[44] = Display_Ram[45];
   Display_Ram[45] = Display_Ram[46];
   Display_Ram[46] = Display_Ram[47];
   Display_Ram[47] = Display_Ram[48];
   Display_Ram[48] = Display_Ram[49];
   Display_Ram[49] = Display_Ram[50];
   Display_Ram[50] = Display_Ram[51];
   Display_Ram[51] = Display_Ram[52];
   Display_Ram[52] = Display_Ram[53];
   Display_Ram[53] = Display_Ram[54];
   Display_Ram[54] = Display_Ram[55];
   Display_Ram[55] = Display_Ram[56];
   Display_Ram[56] = Display_Ram[57];
   Display_Ram[57] = Display_Ram[58];
   Display_Ram[58] = Display_Ram[59];
   Display_Ram[59] = Display_Ram[60];
   Display_Ram[60] = Display_Ram[61];
   Display_Ram[61] = Display_Ram[62];
   Display_Ram[62] = Display_Ram[63];
   Display_Ram[63] = Display_Ram[64];
   Display_Ram[64] = Display_Ram[65];
   Display_Ram[65] = Display_Ram[66];
   Display_Ram[66] = Display_Ram[67];
   Display_Ram[67] = Display_Ram[68];
   /*Display_Ram[68] = Display_Ram[69];
   Display_Ram[70] = Display_Ram[71];
   Display_Ram[71] = Display_Ram[72];
   Display_Ram[72] = Display_Ram[73];
   Display_Ram[73] = Display_Ram[74];
   Display_Ram[74] = Display_Ram[75];
   Display_Ram[75] = Display_Ram[76];
   Display_Ram[76] = Display_Ram[77];
   Display_Ram[77] = Display_Ram[78];
   Display_Ram[78] = Display_Ram[79];
   Display_Ram[79] = Display_Ram[80];
   Display_Ram[80] = Display_Ram[81];
   Display_Ram[81] = Display_Ram[82];
   Display_Ram[82] = Display_Ram[83];
   Display_Ram[83] = Display_Ram[84];
   Display_Ram[84] = Display_Ram[85];
   Display_Ram[85] = Display_Ram[86];
   Display_Ram[86] = Display_Ram[87];
   Display_Ram[87] = Display_Ram[88];
   Display_Ram[88] = Display_Ram[89];
   Display_Ram[89] = Display_Ram[90];
   Display_Ram[90] = Display_Ram[91];
   Display_Ram[91] = Display_Ram[92];
   Display_Ram[92] = Display_Ram[93];
   Display_Ram[93] = Display_Ram[94];
   Display_Ram[94] = Display_Ram[95];
   Display_Ram[95] = Display_Ram[96];
   Display_Ram[96] = Display_Ram[97];
   Display_Ram[97] = Display_Ram[98];
   Display_Ram[98] = Display_Ram[99];
   Display_Ram[99] = Display_Ram[100];
   Display_Ram[100] = Display_Ram[101];
   Display_Ram[101] = Display_Ram[102];*/
   shift_counter++;
   if(shift_counter == 6){
      shift_counter = 0;
      load();}
}

void Display(void)
{

   mask = 0x80;
   scan();
   PCOUT = ~0x01;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x40;
   scan();
   PCOUT = ~0x02;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x020;
   scan();
   PCOUT = ~0x04;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x10;
   scan();
   PCOUT = ~0x08;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x08;
   scan();
   PCOUT = ~0x10;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x04;
   scan();
   PCOUT = ~0x20;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x02;
   scan();
   PCOUT = ~0x40;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;

   mask = 0x01;
   scan();
   PCOUT = ~0x80;
   for(d=0;d<INTEN;d++){}
   PCOUT = 0xff;
}

void clock(void)
{
   PBOUT &= ~0x04;         // clock hi
   PBOUT |= 0x04;         // clock low
}
void strobe(void)
{
   PBOUT &= ~0x01;         // strobe hi
   PCOUT |= 0x01;         // strobe low
}

Logged
marsianpipz
Size C Battery
*****

Pogi/Ganda Points: 9
Offline Offline

Gender: Male
Posts: 237


life is so amazing :D


« Reply #152 on: August 20, 2011, 04:00:50 PM »

pwede bang sama muna din ung header files Cheesy
Logged

"   Life doesn't get easier, you just get stronger.              "
matronell
Size C Battery
*****

Pogi/Ganda Points: 14
Offline Offline

Posts: 173


« Reply #153 on: August 20, 2011, 10:52:03 PM »

hahaha..seryoso..kelangan nyo pa un? hahaha nanjan n lahat un Cheesy
Logged
zed
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 2


« Reply #154 on: January 16, 2012, 02:05:12 AM »

hi, i need help in my c code to implement a real time clock using timer interrupts. hirap pa talaga ako dito. i already initialize timer0 reload at 100 ms. however, adding the isr code to display clock in lcd, i get many error messages. btw, how do i post my crude codes. sana matulungan nyo po ko.
Logged
microlan2008
Size AAA Battery
***

Pogi/Ganda Points: 3
Offline Offline

Posts: 88


live, love, eat, and be happy


« Reply #155 on: January 20, 2012, 05:32:50 PM »

hi, i need help in my c code to implement a real time clock using timer interrupts. hirap pa talaga ako dito. i already initialize timer0 reload at 100 ms. however, adding the isr code to display clock in lcd, i get many error messages. btw, how do i post my crude codes. sana matulungan nyo po ko.

anung klaseng RTC gamit mo? i mean anung interface nya, i2c ba o spi?
Logged
The Philippine Electronics and Technology Forum
   

 Logged
Pages: 1 ... 6 7 [8]   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
zilog encore with 8bit external adc using Dma
PIC Microcontrollers
soul 5 1437 Last post February 18, 2008, 07:30:04 PM
by soul
Request PICMICRO codes here (C Only) « 1 2 ... 13 14 »
PIC Microcontrollers
paranz 264 18279 Last post October 16, 2011, 04:27:00 PM
by fran2no
Zilog Encore EEPROM
Zilog Microcontrollers
SpongeBob 5 1434 Last post February 17, 2010, 10:01:22 PM
by abyssinian
HOW TO PROGRAM ZILOG z8 ENCORE...
Zilog Microcontrollers
NC3 4 620 Last post January 12, 2011, 03:19:46 AM
by NC3
Multiple ADC in Zilog Encore
Zilog Microcontrollers
BotMind 2 212 Last post February 17, 2011, 08:04:46 PM
by marsianpipz
request po sana nang codes..
PIC Microcontrollers
ewan1921 2 113 Last post December 05, 2011, 09:15:51 AM
by SpongeBob
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!