Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

CCS: receiving data packet using RTL8019 driver

Status
Not open for further replies.
Hi,

I am using RTL8019 driver bundled with CCS compiler to receive an arp request. However, the data received after line 2 is not in correct format.

line 2 should start with 0x08 00 (IP), instead of 0x40 00. The packet length is always 0x3ffc :(

I enclosed a screen shot of protocol analyzer, and the result i captured from HyperTerminal, using the RTL8019 driver .
I wish somebody can point me out where i did mistake. thank you.

#include "rcv.h"
#include "rtl8019.c"

BYTE buffer[500];
int16 rx_len;
int i, j , k;

int t;
void main() {

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

nic_init();
i = 0;
j = k = 0;
t = 0;
while(TRUE) {

if (nic_begin_packet_rx() && t == 0) {
i++;
printf("PACKET %4U : length : %4LX \n\r\n\r", i, nic_begin_packet_rx());

for (j=0; j < 0x10; j++) {
for (k= 0; k < 16; k++) {
printf(" %2X ", buffer[j * 16 + k]);
}
printf("\n\r");
}
nic_packet_get_data(buffer, rx_len);
nic_end_packet_rx();

t++;
}

}
}

Result:

PACKET 1 : length : 3FFC

FF FF FF FF FF FF 00 0B CD 55 CB 28 08 06 00 01
40 00 02 61 04 08 80 00 00 24 86 01 10 00 80 40
00 00 40 02 80 41 11 04 00 00 00 00 10 02 85 08
00 00 A0 04 08 20 80 00 00 00 32 00 00 00 80 03
02 A7 40 40 80 45 00 02 00 00 02 00 00 00 01 00
1C 00 00 80 20 0A 01 00 02 08 00 20 00 04 40 00
02 00 08 00 00 0A 42 00 10 9A 00 01 00 00 10 40
80 00 08 80 40 00 00 00 01 20 00 84 04 00 89 80
10 01 08 00 08 20 20 00 14 00 00 04 00 48 00 00
24 00 44 08 01 08 11 04 00 40 80 02 02 40 C0 00
4B 40 10 00 00 90 00 00 08 20 80 00 20 02 00 AE
80 08 02 20 04 00 00 01 00 20 20 61 01 00 00 00
04 30 00 00 03 00 00 02 00 44 00 40 A0 90 00 00
00 08 04 80 00 14 00 00 00 D0 20 01 08 20 10 30
80 A0 00 04 01 31 00 40 00 20 00 82 00 00 A0 00
00 01 80 20 0C 00 24 20 00 82 00 81 01 00 00 00
 

Attachments

  • packet.gif
    packet.gif
    11 KB · Views: 731
I got it right after i modified my code as below. However, nic_begin_packet_rx() still returns an invalid number, eg. 3FFC, since maximum size of a data frame is only 1.6 kbytes.

if (nic_begin_packet_rx() && t == 0) {
i++;
nic_packet_get_data(&buffer[0], 1600);
//nic_packet_get_data(&buffer[16], 16);
//nic_packet_get_data(&buffer[32], 16);
//nic_packet_get_data(&buffer[48], 16);
printf("PACKET %4LX : length : %4LX \n\r\n\r", i, nic_begin_packet_rx());

for (j=0; j < 0x10; j++) {
for (k= 0; k < 16; k++) {
printf(" %2X ", buffer[j * 16 + k]);
}
printf("\n\r");
}
// nic_packet_get_data(buffer, rx_len);
nic_end_packet_rx();
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top