阅读:1295回复:9
好心人。帮我看看我程序这样写可以吗?
;//我用的是72131+1787。我现在自己参考前人的程序,想把一个电台的频率(105。2)直接发到72131里。不知道我
这样写可不可以实现?我在线等。。。谢谢 希望会的朋友帮我看看。 ;//定义72131的连接端口 LC72131_TUNER_CE_PIN equ P1.4 LC72131_TUNER_CL_PIN equ P1.1 LC72131_TUNER_DI_PIN equ P1.3 LC72131_TUNER_DO_PIN equ P1.2 LC72131_POWER_PIN equ P1.5 LC72131_RA_CTL_PIN equ P1.6 LA1787_SD_IN_PIN equ P1.7 ;//lc72141地址 LC72131_SEND_ADDRESS equ 28h LC72131_MODE3_ADDRESS_VALUE equ 94h ;//写入数据 ;// E 0 9 0 6 B ;//p0|P1|p2|p3| P4|p5|p6|P7| p8|p9|P10|p11| p12|P13|p14|P15 |SNS|DVS|CTE|XS |R0|R1|R2|R3 ;//Fm RF=105。2Mhz LC72131_SEND_DATA_LOW equ 0E0h LC72131_SEND_DATA_MID equ 90h LC72131_SEND_DATA_HIG equ 6Bh ;//读出数据 LC72131_READ_DATA_LOW equ 00h LC72131_READ_DATA_MID equ 00h LC72131_READ_DATA_HIG equ 00h ;*********************************************************************** ;*********************************************************************** SETB LC72131_POWER_PIN LC72131_DATA_SHIFT: CLR LC72131_TUNER_CE_PIN NOP NOP ;********************************************************* MOV R0,#08H MOV A,LC72131_SEND_ADDRESS LC72131_DATASHIFT_LOOP1: CLR LC72131_TUNER_CL_PIN NOP NOP RRC A MOV LC72131_TUNER_DI_PIN,C NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN NOP NOP NOP NOP DJNZ R0,LC72131_DATASHIFT_LOOP1 ;********************************************************* NOP SETB LC72131_TUNER_CE_PIN NOP NOP NOP ;********************************************************* MOV R0,#08H MOV A,LC72131_SEND_DATA_LOW LC72131_DATASHIFT_LOOP2: CLR LC72131_TUNER_CL_PIN NOP NOP RRC A MOV LC72131_TUNER_DI_PIN,C NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN NOP NOP NOP NOP DJNZ R0,LC72131_DATASHIFT_LOOP2 ;********************************************************* MOV R0,#08H MOV A,LC72131_SEND_DATA_MID LC72131_DATASHIFT_LOOP3: CLR LC72131_TUNER_CL_PIN NOP NOP RRC A MOV LC72131_TUNER_DI_PIN,C NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN NOP NOP NOP NOP DJNZ R0,LC72131_DATASHIFT_LOOP3 ;********************************************************* MOV R0,#08H MOV A,LC72131_SEND_DATA_HIG LC72131_DATASHIFT_LOOP4: CLR LC72131_TUNER_CL_PIN NOP NOP RRC A MOV LC72131_TUNER_DI_PIN,C NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN NOP NOP NOP NOP DJNZ R0,LC72131_DATASHIFT_LOOP4 ;********************************************************* CLR LC72131_TUNER_CE_PIN NOP NOP NOP NOP END_LC72131_DATA_SHIFT: RET ;*********************************************************************** LC72131_DATA_READ: CLR LC72131_TUNER_CE_PIN NOP NOP ;********************************************************* MOV R0,#08H MOV A,LC72131_MODE3_ADDRESS_VALUE LC72131_READ_DATASHIFT_LOOP1: CLR LC72131_TUNER_CL_PIN NOP NOP RRC A MOV LC72131_TUNER_DI_PIN,C NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN NOP NOP NOP NOP DJNZ R0,LC72131_READ_DATASHIFT_LOOP1 ;********************************************************* NOP NOP SETB LC72131_TUNER_CE_PIN NOP NOP ;********************************************************* SETB LC72131_TUNER_DO_PIN MOV R0,#08H LC72131_DATA_READ_LOOP1: NOP NOP CLR LC72131_TUNER_CL_PIN NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN MOV C,LC72131_TUNER_DO_PIN RRC A NOP NOP NOP NOP DJNZ R0,LC72131_DATA_READ_LOOP1 MOV LC72131_READ_DATA_LOW,A ;********************************************************* MOV R0,#08H LC72131_DATA_READ_LOOP2: ; SETB LC72131_TUNER_DO_PIN NOP NOP CLR LC72131_TUNER_CL_PIN NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN MOV C,LC72131_TUNER_DO_PIN RRC A NOP NOP NOP NOP DJNZ R0,LC72131_DATA_READ_LOOP2 MOV LC72131_READ_DATA_MID,A ;********************************************************* MOV R0,#08H LC72131_DATA_READ_LOOP3: ; SETB LC72131_TUNER_DO_PIN NOP NOP CLR LC72131_TUNER_CL_PIN NOP NOP NOP NOP SETB LC72131_TUNER_CL_PIN MOV C,LC72131_TUNER_DO_PIN RRC A NOP NOP NOP NOP DJNZ R0,LC72131_DATA_READ_LOOP3 MOV LC72131_READ_DATA_HIG,A ;********************************************************* NOP NOP CLR LC72131_TUNER_CE_PIN ; CLR LC72131_TUNER_CL_PIN NOP NOP END_LC72131_DATA_READ: RET end |
|
1楼#
发布于:2006-03-27 03:41
<P>大家帮帮我好吗?真的很需要你指点一下的。我已搞了好久都没进展的。斑竹,在吗?指点我一下。</P> |
|
2楼#
发布于:2006-03-27 04:28
|
|
4楼#
发布于:2006-03-28 20:02
#include <REG51.H> #include "intrins.h" sbit PIN_TUNER_CE=P1^4; sbit PIN_TUNER_CL=P1^1; sbit PIN_TUNER_DI=P1^3; sbit PIN_TUNER_DO=P1^2; sbit PIN_POWER=P1^5; sbit PIN_RA_CTL=P1^6; sbit PIN_SD_IN=P1^7; #define nop _nop_(); #define LC72131_DELAY() {nop;nop;nop;}; //--------------------------------------------------------------------------- // Write_LC72131_Addr // addr: the addr of the control register // value: the value to set to //--------------------------------------------------------------------------- static void Write_LC72131_Addr(unsigned char addr) { unsigned int i; PIN_TUNER_CE = 0; PIN_TUNER_CL = 1; LC72131_DELAY(); for (i = 8; i>0; --i) { PIN_TUNER_CL = 0; LC72131_DELAY(); if (addr & 0x01) PIN_TUNER_DI=1; else PIN_TUNER_DI=0; addr >>= 1; LC72131_DELAY(); PIN_TUNER_CL = 1; LC72131_DELAY(); } } //--------------------------------------------------------------------------- // Write_LC72131 // addr: the addr of the control register // value: the valude to set to //--------------------------------------------------------------------------- static void Write_LC72131(unsigned char addr, unsigned long value){ unsigned int i; // Send the addr byte first ------------// Write_LC72131_Addr(addr); PIN_TUNER_CE = 1; LC72131_DELAY(); for (i = 24; i>0; --i){ PIN_TUNER_CL = 0; LC72131_DELAY(); if (value & 0x01) PIN_TUNER_DI=1; else PIN_TUNER_DI=0; value >>= 1; LC72131_DELAY(); PIN_TUNER_CL = 1; LC72131_DELAY(); } PIN_TUNER_CE = 0; } void main() { PIN_POWER=1; while(1) { // E 0 9 0 6 3 //p0|P1|p2|p3| P4|p5|p6|P7| p8|p9|P10|p11| p12|P13|p14|P15 |SNS|DVS|CTE|XS |R0|R1|R2|R3 //note:Fm RF=105.2Mhz //xs=0 4.5 // 0 5 0 0 0 1 //ioc1|ioc2|io1|io2 |B01|B02|B03|B04 |DNC|DOC0|DOC1|DOC2 |UL0|UL1|DZ0|DZ1 |GT0|GT1|TBC|DLC |IFS|TEST0|TEST1|TEST2 //B02=Fm电源;B03=AM电源。 Write_LC72131(0x28, 0x36090E); LC72131_DELAY(); Write_LC72131(0X29, 0x100050); } } //我修改了一下。这样也不能打通105。2的台。希望前辈们指点一下那里错了。 [此贴子已经被作者于2006-3-29 10:49:40编辑过]
|
|
5楼#
发布于:2006-03-28 20:11
[此贴子已经被作者于2006-3-28 15:44:59编辑过]
|
|
6楼#
发布于:2006-03-29 18:25
|
|
7楼#
发布于:2006-03-29 18:45
|
|
8楼#
发布于:2006-03-30 01:31
|
|
|
9楼#
发布于:2006-03-31 04:29
我发现我在传送数据有点问题。修改后还是不行的。为什么我控制不了锁相环的?FM和AM电源脚都是被拉低的。高手救命啊。搞了两个星期了。都没点进展的。工作也没了。学习又没进展。真是郁闷死了。 请大家帮我看看,为什么这样写还是不行的?真的很感谢的。 #include <REG51.H> #include "intrins.h" sbit PIN_TUNER_CE=P1^4; sbit PIN_TUNER_CL=P1^1; sbit PIN_TUNER_DI=P1^3; sbit PIN_TUNER_DO=P1^2; sbit PIN_POWER=P1^5; sbit PIN_RA_CTL=P1^6; sbit PIN_SD_IN=P1^7; #define nop _nop_(); #define LC72131_DELAY() {nop;nop;nop;}; //--------------------------------------------------------------------------- // Write_LC72131_Addr // addr: the addr of the control register // value: the value to set to //--------------------------------------------------------------------------- static void Write_LC72131_Addr(unsigned char addr) { unsigned int i; PIN_TUNER_CE = 0; PIN_TUNER_CL = 1; LC72131_DELAY(); for (i = 8; i>0; --i) { PIN_TUNER_CL = 0; LC72131_DELAY(); if (addr & 0x01) PIN_TUNER_DI=1; else PIN_TUNER_DI=0; addr >>= 1; LC72131_DELAY(); PIN_TUNER_CL = 1; LC72131_DELAY(); } } //--------------------------------------------------------------------------- // Write_LC72131 // addr: the addr of the control register // value: the valude to set to //--------------------------------------------------------------------------- static void Write_LC72131(unsigned char addr, unsigned long value){ unsigned int i; // Send the addr byte first ------------// Write_LC72131_Addr(addr); PIN_TUNER_CE = 1; LC72131_DELAY(); for (i = 24; i>0; --i){ PIN_TUNER_CL = 0; LC72131_DELAY(); if (value & 0x000001) PIN_TUNER_DI=1; else PIN_TUNER_DI=0; value >>= 1; LC72131_DELAY(); PIN_TUNER_CL = 1; LC72131_DELAY(); } PIN_TUNER_CE = 0; } void main() { PIN_POWER=1; while(1) { // E 0 9 0 6 3 //p0|P1|p2|p3| P4|p5|p6|P7| p8|p9|P10|p11| p12|P13|p14|P15 |SNS|DVS|CTE|XS |R0|R1|R2|R3 //note:Fm RF=105.2Mhz //xs=0 4.5 // 0 5 0 0 0 1 //ioc1|ioc2|io1|io2 |B01|B02|B03|B04 |DNC|DOC0|DOC1|DOC2 |UL0|UL1|DZ0|DZ1 |GT0|GT1|TBC|DLC |IFS|TEST0|TEST1|TEST2 //B02=Fm电源;B03=AM电源。 Write_LC72131(0x28, 0x36090E); LC72131_DELAY(); Write_LC72131(0X29, 0x100051); } } [此贴子已经被作者于2006-3-31 16:29:45编辑过]
|
|