• 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: i/o模擬uart 傳接收
#6
中級會員
中級會員


查看用戶資訊
版主以及各位大大 是否有相關書籍是 i/o模擬RS232傳接收的範例程式或者是觀念 小弟在google找了很久 都沒找到ㄧ本書籍是符合小弟的需求 麻煩各位大大以及版主

發表於: 2008/11/28 11:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: i/o模擬uart 傳接收
#5
中級會員
中級會員


查看用戶資訊
#include <p18f4620.h>

#define tx  PORTCbits.RC3

unsigned char num[10]={0};

void putchar(char num);
void Delay(unsigned long int t);    

void main(void)
{        
  
TRISC=0x02;
   
tx 1;
    while(
1)
    {
     
putchar(0xff);
     
putchar(0xd0);
     
putchar(0x3f);
     
putchar(0x6f);
    }
}
////////////////////////////////////////////
void putchar(char num)
{
 
unsigned int cnt;
    
tx 0;
          
Delay(5);
        for(
cnt=0;cnt<8;cnt++)
        {
            
tx=num%2;
            
num=num/2;
            
Delay(2);            
            
Nop();Nop();Nop();Nop();Nop();    
        }
        
Delay(1);
        
Nop();Nop();Nop();Nop();
          
tx 1;
        
Delay(1000);
    
}
///////////////////////////////////////////    
void Delay(unsigned long int t)
{
    
unsigned long int i;
    for(
i=0;i<=t;i++);
}
//////////////////////////////////////////

我現在傳送4byte給tx 可是vb那邊接收到的值 有兩個是錯誤的耶 vb那邊顯示 01 30 3f 6f 簡單來說 我有試過傳送幾個值
0x55 0x30都可以 0xff 0xa0這幾各值就不可以 照理說我用0x55傳送時 vb那邊可以接收到55 我也用示波器去看他的包率是9600 為什麼我換其它直傳送時就怪怪的 有時會對 有時會不對 難道是時間還不過準確嗎?? 麻煩版主和各位大大 幫我解開心中疑惑 謝謝

還有我的 i/o模擬 rs-232 的接收 到現在還是沒有程式架構的概念 拜託樓上大大 是否有比較易懂又可寫出 i/o模擬 rs-232 的接收程式 小弟在此感激不盡 我需要用來接收AI MOTOR-701的資料 謝謝

發表於: 2008/11/26 9:14

Edited by j813055 on 2008年11月26日 11:44:17
Edited by Ryang on 2008年11月27日 11:33:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: i/o模擬uart 傳接收
#4
中級會員
中級會員


查看用戶資訊
你好!

突然發現你的程式很明顯少了 start bit 的部分.
建議你加上 start bit 在實際的傳送資料前面, 再試一下吧!

#include <p18f4620.h>
#define tx PORTCbits.RC3 

void Delay(unsigned long int t)
{
unsigned long int i;
for(
i=0;i<=t;i++);
}

void main(void)

unsigned int SD,cnt,i=0;
TRISC=0x02;
tx 1;
while(
1)
     {
     
SD=0x55;

[
color=CC0000]     // 在這裡加上 start bit, 大概是像以下這兩行
     // *** tx = 0;
     // *** Delay(k);[/color]
     
for(cnt=0;cnt<8;cnt++)
       {
       
tx=SD%2;
       
SD=SD/2;
       
Delay(1); 
       
Nop();Nop();Nop();Nop(); 
       }
     
tx 1;
     
Delay(1000);
     }
}


正確的 0x55 傳送順序     start bit,   bit0,      bit1,     bit2,   bit3,   bit4,   bit5,   bit6,   bit7,   stop bit
                             0         1          0         1       0       1       0       1       0         1

少1個 start bit 後的錯誤   
---       ---    錯誤的start     1       0       1       0       1       0         1        1    stop 0xD5

發表於: 2008/11/25 23:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: i/o模擬uart 傳接收
#3
中級會員
中級會員


查看用戶資訊
#include <p18f4620.h>
#define tx PORTCbits.RC3
void Delay(unsigned long int t)
{
unsigned long int i;
for(i=0;i<=t;i++);
}
void main(void)
{
unsigned int SD,cnt,i=0;
TRISC=0x02;
tx = 1;
while(1)
{
SD=0x55;
for(cnt=0;cnt<8;cnt++)
{
tx=SD%2;
SD=SD/2;
Delay(1);
Nop();Nop();Nop();Nop();
}
tx = 1;
Delay(1000);
}
}
這各程式是i/o模擬rs-232的傳送 我送0x55
我測試這各程式它的包率是9600 我適用示波器去測量的 可是為什麼我用vb接收的值並不是收到55的訊號而是d5的訊號 麻煩版主以及各位大大 謝謝

發表於: 2008/11/25 21:35
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: i/o模擬uart 傳接收
#2
版主
版主


查看用戶資訊
http://checko.blogspot.com/2005/09/ua ... -hardware-1-software.html

http://supp.iar.com/Support/?note=88469

一般 Software UART 發比較簡單,即時的接收比較要考慮。接收我會使用 INT0 做 Low 的中斷觸發後再啟動 Timer 來做計時的接收。而且使用軟體接收最好 Byte 與 Byte 之間有比個 time 的間隔會比較好。
要是不很清楚打 0800-717-718 討論,用寫的比較難以說明其作法。

發表於: 2008/11/25 14:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


i/o模擬uart 傳接收
#1
中級會員
中級會員


查看用戶資訊
請問版主以及各位大大 小弟我最近在測試i/o模擬uart 傳接收 到現在還不知道程式架構如何著手 是否有程式範例 包率9600
單晶片是用PIC18F4620 我已經把那ㄧ組usart拿去用藍芽晶片 我還需要另外ㄧ組usart的功能 所以我需要用i/o模擬的方式再模擬一組usart的傳接收 我是用c語言寫的 麻煩各位大大 小弟我感激不盡 謝謝

發表於: 2008/11/25 11:30
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... ]

教育訓練中心

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