有关UART1的使用,我怎么调都调不过,这边问问大家有什么办法不?
问题1.UART1发送,只能在开机的第一次可以发送第一个字节,
以后在查询发送寄存器的时候,总是为不空的,然后就不能再发送了
芯片是R8C/2B,片内震荡20MHz,相似的配置在UART0是可以正常使用的
问题2.还有个关于编译器的问题,提示信息:
H:\Workspace\IIIB_0806\IIIB_0806\sect30.inc(112) : Warning (ln30): H:\Workspace\IIIB_0806\IIIB_0806\Debug\ncrt0.r30 : 'ROMDATA' section 'vector' is overlapped on the 'program' from FEDCH to FEDCH
H:\Workspace\IIIB_0806\IIIB_0806\sect30.inc(185) : Error (ln30): H:\Workspace\IIIB_0806\IIIB_0806\Debug\ncrt0.r30 : 'ROMDATA' section 'fvector' is overlapped on the 'program' from FFDCH to FFFFH
相似的位置还有 section “rom_FE”,“rom_FO”
前面有个相关的帖子是也是这样的错误,但是我这边不知道怎么解决掉这个问题,
sect30.inc文件中,除了中断地址之外我是没有修改的.
UART1相关的源码:
/************************************************************************************
Name: uart_init
Parameters: None
Returns: None
Description: Initial setting of UART SFR
************************************************************************************/
void uart1_init(void)
{
UINT i;
asm("FCLR I"); /* Interrupt disabled */
p6|=0x20;
u1pinsel=1;
pd6|=0x20;
pd6&=~0x80;
//u1c0 &= 0x08;
u1c0 = 0x00;
u1c1 = 0x00;
u1mr = 0x05;//8 位数据,1个停止位,无校验
u1brg = 124;//9600
s1tic = 0x05; /* Enable UART0 transmit Interrupt */
s1ric = 0x05; /* Enable UART0 receive Interrupt */
te_u1c1=1;//允许发送
re_u1c1=1;//允许接受
asm("FSET I"); /* Interrupt enable */
}
#pragma INTERRUPT /B UART0_transINT 19
void UART1_transINT(void)
{
//ti_u1c1=1;
}
#pragma INTERRUPT /B UART0_recvINT 20
void UART1_recvINT(void)
{
UINT8 t;
if(ri_u1c1==1&&sum_u1rb==0)
{
t=u1rbl;
}
re_u1c1=1;
}
void UART1_SendMem(const char *buf,UINT8 n)
{
UINT8 i;
i=0;
while(i<n)
{
while(!ti_u1c1); //等待发送寄存器空闲
u1tb=buf[i];
i++;
}
while(!ti_u1c1);
//while(!txept_u1c0);
}
void UART1_Send(const char *buf)
{
UART1_SendMem(buf,strlen(buf));
}
void UART1_SendChar(UINT8 ch)
{
while(!ti_u1c1);
u1tb=ch;
while(!ti_u1c1);
//while(!txept_u1c0);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
中断向量
*/
.section vector,ROMDATA
.org __VECTOR_ADR__
.if 1
.lword dummy_int ; vector 0
.lword dummy_int ; vector 1
.lword dummy_int ; vector 2
.lword dummy_int ; vector 3
.lword dummy_int ; vector 4
.lword dummy_int ; vector 5
.lword dummy_int ; vector 6
.lword dummy_int ; vector 7
.lword dummy_int ; vector 8
.lword dummy_int ; vector 9
.lword dummy_int ; vector 10
.lword dummy_int ; vector 11
.lword dummy_int ; vector 12
.lword dummy_int ; vector 13
.lword dummy_int ; vector 14
.lword dummy_int ; vector 15
.lword dummy_int ; vector 16
;.lword dummy_int ; vector 17
.glb _UART0_transINT
.lword _UART0_transINT ;UART0发送中断
;.lword dummy_int ; vector 18
.glb _UART0_recvINT
.lword _UART0_recvINT ;UART0 接收中断
;.lword dummy_int ; vector 19
.glb _UART1_transINT
.lword _UART1_transINT ;UART1发送中断
;.lword dummy_int ; vector 20
.glb _UART1_recvINT
.lword _UART1_recvINT ;UART1 接收中断
.lword dummy_int ; vector 21
;.lword dummy_int ; vector 22
.glb _timerRa_INT
.lword _timerRa_INT ;定时器A中断
;.lword dummy_int ; vector 23
.glb _timerRb_INT
.lword _timerRb_INT ;定时器中断B
.lword dummy_int ; vector 24
.lword dummy_int ; vector 25
.lword dummy_int ; vector 26
.endif