Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

tv-tuner for 89c2051. ALL C-language OK!!!

Status
Not open for further replies.

z543g

Junior Member level 1
Joined
Jan 2, 2002
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
222
_delay_ms iar

SAA1064 & TV-tuner CODE.

use 's iar c comiler. you have't help.

successful !!!! good c source function.

* i2c-bus function.

void i2c_start();
void i2c_stop();
int i2c_clock();
int i2c_ack();
int i2c_read();
int i2c_write(char data);

* saa1064 function
void disp_led(unsigned int index,unsigned char count);

* tv-tuner (tsa5520) function
void tuner(unsigned int band,unsigned char count);
/* bs1 output -- ch2~5 */
/* bs2 output -- ch6~20 */
/* bs3 output -- ch21~40 */
/* bs4 output -- ch41~69 */

possible cable function.

* t_cp,t_plus,t_minus function
void key_in();

* video decoder function ( use cable)
void v_decoder(unsigned char val1,unsigned char val2);


ha! ha! ha! ha! end.....
 

z543g

Junior Member level 1
Joined
Jan 2, 2002
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
222
tsa5520 code

:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
/******************************************************/
/* SAA1064 LED DISPLAY & TV-TUNER PROGRAM */
/* */
/* */
/* http://kms2000.wo.to tun_led.c (Iar v5.0) */
/* http://www.woe.de.vu tun_led.asm */
/* */
/* C-langage programmer: Kang Yong Koo (z543g) */
/* Date : 2002.5.6 */
/******************************************************/

#include <io51.h>

/***** Saa1064 Led Display Code_Table *****/

/* 0 1 2 3 4 5 6 7 8 9 */
char disp_tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
/* A b C d E f P r h */
0x77,0x7c,0x39,0x5e,0x79,0x71,0x73,0x50,0x74};

/***** TV-tuner Samsung TCPN7082PC27A (TSA5520) Code_Table *****/

/* 0 (not use) 1 (not use) 2 ch 3 ch */
char freq_tab[][4]={{0x00,0x00,0x00},{0x00,0x00,0x00},{0x06,0x60,0x01},{0x06,0xaf,0x01},
/* 4 ch 5 ch 20 ch */
{0x07,0x0f,0x01},{0x07,0x5f,0x01},{0x1f,0xe2,0x08}};

static unsigned char i2c_nackcount = 0;
static unsigned int prog_index;
static unsigned int ch_index;
static unsigned int get_idx;

static unsigned char key_in;

static unsigned int eeprom_count;

#define I2C_SCL P1.0
#define I2C_SDA P1.1

#define T_CP 0x08 /* C^P */
#define T_PLUS 0x10 /* + */
#define T_MINUS 0x20 /* - */

void delay_ms(int t)
{
while(t--);
}

void i2c_start(void)
{
I2C_SDA=1;
I2C_SCL=1;
delay_ms(1);
I2C_SDA=0;
delay_ms(1);
I2C_SCL=0;
delay_ms(1);
}

void i2c_stop(void)
{
I2C_SDA=0;
delay_ms(1);
I2C_SCL=1;
delay_ms(1);
I2C_SDA=1;
delay_ms(1);
}

int i2c_clock(void)
{
unsigned int sda_value;

I2C_SCL = 1;
delay_ms(1);
sda_value =I2C_SDA;
I2C_SCL = 0;
delay_ms(1);

return(sda_value);
}

int i2c_ack(void)
{
unsigned int count;

I2C_SDA = 1;
I2C_SCL = 1;
delay_ms(1);

count = I2C_SDA;

I2C_SCL = 0;
delay_ms(1);
I2C_SDA = 0;
delay_ms(1);

return(count);
}

int i2c_read(void)
{
unsigned char data count,b;

for(count=0; count<=7; count++) {
I2C_SDA = 1;
b = b<<1;
b |= i2c_clock();
}
return(b);
}

void i2c_write(unsigned char b)
{
unsigned char data count;

for(count=0; count<=7; count++) {
if((b & 0x80)==0)
I2C_SDA = 0;
else
I2C_SDA = 1;

b = b<<1;
i2c_clock();
}

i2c_ack();
}

/*
void store_eeprom(unsigned char eep_data1,unsigned char eep_data2)
{

i2c_start();
i2c_write(0xa0);
eeprom_count = eep_data1;
i2c_write(eeprom_count);
save_idx = eeprom_count;
eeprom_count = eep_data2;
i2c_write(eeprom_count);
get_idx = eeprom_count;
i2c_stop();
}
*/

void disp_led(int num,unsigned char disp_num)
{
unsigned char disp[1];
unsigned char count;

i2c_start();
i2c_write(0x70);
i2c_write(0x00);
i2c_write(0x37);

switch(num) {
case 0:
disp[0] = (disp_num%10);
count = disp[0];
i2c_write(disp_tab[count]);

disp[1] = (disp_num%100)/10;
count = disp[1];
i2c_write(disp_tab[count]);

i2c_write(disp_tab[17]); "r"
i2c_write(disp_tab[16]); "P"
break;
case 1:
disp[0] = (disp_num%10);
count = disp[0];
i2c_write(disp_tab[count]);

disp[1] = (disp_num%100)/10;
count = disp[1];
i2c_write(disp_tab[count]);

i2c_write(disp_tab[18]); "h"
i2c_write(disp_tab[12]); "C"
break;
default: break;
}
i2c_stop();
}

void tuner(unsigned char data_code)
{
int i,count;

i2c_start();
i2c_write(0xc2);

for(i=0; i<1; i++) {
i2c_write(freq_tab[data_code]);
i2c_write(freq_tab[data_code][i+1]);
count=i+2;
}
i2c_write(0xce);

i2c_write(freq_tab[data_code][count]);
i2c_stop();
}

void delay2()
{
int i,j;

for(i=0; i<150; i++) {
for(j=0; j<150; j++);
}
}

void main(void)
{
int count;

prog_index = 0;
ch_index = 2;

disp_led(count,prog_index);
tuner(ch_index);

while(1) {
key_in = ~P1;

if(key_in==T_CP) {
if(count<1) count++; else count=0;
delay2();
}

if(count) {
disp_led(count,ch_index);
tuner(ch_index);
if(key_in==T_PLUS) {
if(ch_index<6) ch_index++; else ch_index=2;
get_idx = ch_index;
delay2();
}
if(key_in==T_MINUS) {
if(ch_index>2) ch_index--; else ch_index=6;
get_idx = ch_index;
delay2();
}
} else {
disp_led(count,prog_index);
if(key_in==T_PLUS) {
if(prog_index<10) prog_index++; else prog_index=0;
delay2();
}
if(key_in==T_MINUS) {
if(prog_index>0) prog_index--; else prog_index=10;
delay2();
}
}
}
} :D
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top