• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 為何APP0001板之RS-232收不到資料?
#6
版主
版主


查看用戶資訊
這個程式應該是從 WAP002 workshop 的練習六改過來的吧!

AP001 的板子在出貨時就是載入這個練習的溫控程式,與RS-232溝通應該沒問題。 設個中斷點在接收程式吧! 檢查一下RS-232 是正確的收到資料。

要是再不行抓下練習六的程式重新燒錄測試,再不行拿板子到 Microchip 找我們。

發表於: 2005/3/31 17:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何APP0001板之RS-232收不到資料?
#5
初級會員
初級會員


查看用戶資訊
有的!在InitializeUSART()這個FUNCTION CALL就有設定了.
這個程式是修改WAP002LAB之ANS4內程式(放在init_MCU.c中),不過已經被我改成4800bps了.不過還是謝謝您!
更希望MicroChip的高手及版主們,可以幫忙解決!
謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝
/************************************************
//* Function: Initialize USART *
//* - Initialize the RS-232 communication *
//* - Disable Interrupr for TxD *
//* - Enable Interrupt fro Rxd *
//* - Format: 4800, N, 8, 1 *
//************************************************
void InitializeUSART(void)
{
TRISCbits.TRISC7=1; // Set input for RXD
TRISCbits.TRISC6=0; // Set output for TXD
RCSTAbits.SPEN=1; // Enable USART Module

OpenUSART( USART_TX_INT_OFF // Set TXSTA Reg. =0b00100100
& USART_RX_INT_ON // Set RCSTA Reg. =0b10010000
& USART_ASYNCH_MODE
& USART_EIGHT_BIT
& USART_CONT_RX
& USART_BRGH_HIGH
,207); // Set SPBRG=207, Baud Rate = 4800 @16MHz

IPR1bits.RCIP=1; // Set Receive of USART are High priority
PIE1bits.RCIE=1; // Enable RxD Interrupt
}


[quote]
Herry 寫道:
Hello rtaur ...
我也是玩PIC沒有多久...
我想你的程式裡面沒有見到USART的設定的部份...如baud rate,USART_RX_INT_ON等....

發表於: 2005/3/31 10:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何APP0001板之RS-232收不到資料?
#4
新會員
新會員


查看用戶資訊
Hello rtaur ...
我也是玩PIC沒有多久...
我想你的程式裡面沒有見到USART的設定的部份...如baud rate,USART_RX_INT_ON等....
OpenUSART( USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE
& USART_EIGHT_BIT
& USART_CONT_RX
& USART_BRGH_HIGH ,129);
還有相對應的中斷致能的bit要設定或啟動喔...

這是我注意到的部份...如有錯誤請多多包含...也希望你寫程式順利囉!!!

發表於: 2005/3/31 8:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何APP0001板之RS-232收不到資料?
#3
初級會員
初級會員


查看用戶資訊
有沒想到人知道程式那裡有問題?
謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝!

發表於: 2005/3/30 19:23
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何APP0001板之RS-232收不到資料?
#2
初級會員
初級會員


查看用戶資訊
附上main.h的資料


//* 宣告所使用的含入檔
//***********************************************************
#include <p18f452.h>
#include <delays.h>
#include <stdlib.h>
#include <string.h>
#include <timers.h>
#include <i2c.h>
#include <adc.h>
#include <usart.h>


//* 函數原型宣告
//***********************************************************

// Declaration file for Main.c related subroutines
void LCD_Temp_Update(void) ;
void VT_100_Update(void );
void Print_Temperature(int Data);
void Print_Byte(unsigned char Byte);
void EEPROM_Update(void);
void EE_Write (unsigned char, unsigned char);
unsigned char EE_Read (unsigned char);
void isr_high_direct(void);
void isr_high(void);
void isr_low_direct(void);
void isr_low(void);


// Declaration file for Init_MCU.c related subroutines

void InitializePORT(void) ;
void InitializeTMR1(void) ;
void InitializeINTs(void) ;
void InitializeAD(void) ;
void InitializeUSART(void );
void Initialize_I2C_Master(void);

// Declaration file for WAP_LCD.c related subroutines

void OpenLCD (void) ;
void WriteCmdLCD ( unsigned char ) ;
void WriteDataLCD( unsigned char ) ;
void putsLCD( char * ) ;
void putrsLCD( const rom char * ) ;
void putcLCD( unsigned char ) ;
void puthexLCD( unsigned char ) ;
void LCD_Set_Cursor( unsigned char , unsigned char ) ;
void LCD_CMD_W_Timing( void ) ;
void LCD_L_Delay( void ) ;
void LCD_S_Delay( void ) ;
void LCD_DAT_W_Timing ( void ) ;

// Declaration file for Read_Temp.c related subroutines

unsigned Read_TC74_Temperature(void) ;
int Read_TC1047_Temperature( void);

// Declaration file for VT100.c related subroutines

void VT100_puthex(unsigned char);
void VT100_Fill_Screen(unsigned char);
void InitializeVT100(void);
void VT100_ESC(void);
void VT100_Clear_Screen(void);
void VT100_Clear_Right (void );
void VT100_Clear_Line (void);
void VT100_Cursor_Up (unsigned char Xn);
void VT100_Cursor_Down (unsigned char Xn);
void VT100_Cursor_Right (unsigned char Yn);
void VT100_Cursor_Left (unsigned char Yn);
void VT100_Cursor_Position (unsigned char Xn, unsigned char Yn);
void VT100_Cursor_Index (void);
void VT100_Cursor_R_Index (void);
void VT100_Cursor_Home (void);
void VT100_Cursor_N_Line (void);

// Declaration file for Rec_Cmd.c related subroutines

void Rec_Cmd_Check(void);
void Modify_T2_Max(void);
void Modify_T2_Min(void);
void Cooling_Auto(void);
void Cooling_Shutdown(void);
int Get_3_Digital(void);

發表於: 2005/3/30 15:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


為何APP0001板之RS-232收不到資料?
#1
初級會員
初級會員


查看用戶資訊
以下是用rs-232接收來自終端機字元,
然後顯示在LCD之程式,且輸出到port D
為何都收不到,那裡出錯?
謝謝

#include "main.h"

#pragma idata access My_RAM_2

near unsigned char Rec_Data=0;

#pragma idata

void main(void)
{
char Title[16]="The DATA System"+0x00;
char p;

// Initial portD
TRISD=0x00;
PORTD=0x00;
OpenLCD();
InitializeUSART();
LCD_Set_Cursor(0,0);
putsLCD(Title);

LCD_Set_Cursor(1,0);
putcLCD('R');
LCD_Set_Cursor(1,1);
putcLCD(':');


while (1)
{
p=Rec_Data;
LCD_Set_Cursor(1,3);
putcLCD(p);
PORTD=P;
Delay10KTCYx(500);

}
}

//************************************************
//* Function: isr_high_direct *
//* - Direct execution to the actual *
//* Hi-priority interrupt code. *
//************************************************
#pragma code isrhighcode = 0x0008

void isr_high_direct(void)
{
_asm //begin in-line assembly
goto isr_high //go to isr_high function
_endasm //end in-line assembly
}
#pragma code

//************************************************
//* Function: isr_high(void) *
//* High priority interrupt: *
//* - Received a serial data from RS-232 *
//* Save the received data to buffer Rec_Data*
//************************************************
#pragma interrupt isr_high

void isr_high(void)
{
if (DataRdyUSART())
{
Rec_Data=ReadUSART(); // Get RS-232 data
}

}
#pragma code

發表於: 2005/3/30 7:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------