Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

position of Address in a frame

Status
Not open for further replies.
How are you calculating checksum?

I think CR = 0A and 0D

The checksum is a 2's complement, if you have a 2 bytes, you do: byte1 + byte2 = 0x..... The result is then inverted(if it is a 0,change it into a 1 or if it a 1,change it into 0) and add 1 to the inverted byte.

No you are wrong,CR=0x0D and LF= 0x0A
 

show an example of checksum calculation.
There are 3 types of checksum, I am using 2's complement:

1010 1001 + 00110 1001 = 1110 0010
1110 0010 ==>0001 1101(inverted) +1= 0001 1110 (2's complement)
 
Last edited:

but you have 3 bytes in your frame other than CR, stx and etx.
 

I was just explaining to you how checksum's been performed,for my frame, I will add <data>+<add>+<data> and <CR>, I am not including the delimiters.

I am off, we will carry on tomorrow.;-)
 

We've just found out that a carriage return is include by the software in the frame.
I need to allow 9-bit tranmission for the slave code.
 

About the carriage return, we found that yesterday itself. Does your slave communicate with master using 9bit transmission or does your slave communicates with RS485 device with 9bit transmission?
 

Yes, the master communicates with the slave using 9bit tranmission, it has to be this way.
My slave must communicate with RS485 device with 9bit transmission as well
 

I just need to modify UART_init in both codes(master and slaves_enabling 9 bit transmission.
 

There is no big changes, just two lines:


RCSTAbits.RX9 = 1; //1 = 9-bit Receive Enable bit
TXSTAbits.TX9=1; //9 bit tranmission
 

send data frame from your managers's software to master PIC. Write the received frame to eeprom in your PIC. Then disconnect your managers software because you have to use com port with reatterm. Now reset you PIC and you should read your eeprom contents and send it to uart and receive it in realterm . See what data comes.

if you write data (frame 5 bytes) to eeprom addresses like 0x00, 0x01, 0x02, 0x03, 0x04, then read those address and send the read data to realterm.

Code:
dont_read_now = 0;
dont_write_now = 0;

if(dont_write_now == 0) {
	for(i = 0; i < 5; i++) {
	
		eepromwrite(i, result[i]);
		dont_read_now = 1;
		dont_write_now = 1;

	}
}

if(dont_read_now == 0) {
	
	for(i=0;i<5;i++) {
		WriteUSART(eeprom_read(i);
	}
        dont_read_now = 1;

}

Have you configured RCSTA register for UART receiving? see page no 229 here http://www.cis.upenn.edu/~lee/06cse480/data/pic-18f2680.pdf
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top