This week I worked on the UART communication. My task is to transmit and receive the bytes of data via the RS232 port of the PICDEM.net 2. Dr. Shawn gave me a brief on the process and introduced the minicom program to me, in order for me to verify whether there is transmission of data. After reading and researching, I wrote a simple code of UART but it only generated corrupted words. I suspected that the problem behind is the baud rate, because the SPBRG register value is obtained through manual calculation. I double checked whether there is mistake in calculation but the problem still remain, therefore I just used a straight forward method, referred on the datasheet and it worked. After one day of working, I able to transmit the data from PIC to the server. However, there are some problems on receiving the data. Fortunately, Dr. Shawn guided me and eventually I was able to achieve the goal.
After the simple UART communication, I continue on another assigned task, SPI (Serial Peripheral Interface) communication between PIC with the 25LC256 series EEPROM. It required a good understanding on the principle behind. I was able to find numerous examples available from the microchip website giving instructions on the aspects of coding for SPI communication. The most critical issue is sending the command and address to the EEPROM, there are certain protocols need to be followed and all these available in the 25LC256 datasheet. I designed a simple program to send the command but the result cannot be obtained. Hence, I tried to use the library of spi.h to solve it but the result remain.
The main problem is I can’t verify the problem occurs at which stage. This is because to check the output, I need successfully to run both read and write operation, then display the data in EEPROM through the minicom. The errors can be anywhere and I had real difficulties in finding it out. I double checked on the C18 complier library but error still remain unknown. In order to solve it, wrote a simplest program of writing and reading of one byte character at address of 0x0000. Next, I used a fundamental method of trial and error to find out the problem. After hours of working, the code was finally able to operate. Since the basic structure is done, I continued to develop it and lastly, both byte and page operation were able to work.