GPIO’s, UARTS and SD Cards… First impressions
Running to the bus-stop to try to catch the 9:00am UCSI bust before it runs away, all I could think was “God, I don’t want to be late on the first day!”. But the butterflies in my stomach gave me enough of a kick to get on the bus in time, and although some pretty terrible traffic tried to derail my hopes and dreams of the perfect first day at work, I managed to touch base at the front door at 9:58am.
Fresh from the little confidence gained from being on time, Dr. Shawn ran me through the documentation needed and helped me set up my account and device. Correspondingly, I was introduced to the PICDEM.net 2 development board. What a beauty! Yet oddly intimidating. I was informed that I will be working on the project that utilizes this board so I needed to get to know it. For this week, I was asked to get the GPIO working and demonstrate it via a simple “Hello World” program and use the LED’s as visual outputs. The rest of my first day was spent reading up on the board and trying to get the LED’s to behave, which I ultimately managed to do once I understood the trick behind using the Delay library. Later during the week, I kept tweaking the program to get a more sophisticated output and created some useful functions like “LED_BLINK” that I could use for other programs later (particularly for testing).
It was not smooth sailing on the first 5 days though as I was bamboozled by the boards EUSART functions. Admittedly, I had never encountered the concept or usage of Serial Ports or Minicom so I was quite confused at first and went down the wrong lane to look for answers. Thankfully, I was dragged to the correct path and once I got a hang of the C18 compiler libraries functions for the USART, I was able to develop a simple program that asks the user for a character in Minicom and once any character is sent to the PIC, the next character on the ASCII table is sent back and displayed (i.e. user sends ‘a’, PIC send back ‘b’). A couple of interesting issues popped up during this enlightening exercise.. a while/for loop as needed to nest the sending data process as the USART kept closing before the last bit could go through. This caused the appearance of wrong characters and sometimes no data sent to Minicom at all. The other issue that is yet to be resolved is that if multiple characters are sent to the PIC (i.e. user pressing ‘a’,’s’,’d’) simultaneously, the program get stuck in an infinite busy state. It’s fair to say that the problem is cause by the BUSY1USART function in the program and the problem could be easily resolved, so I’m hopeful I can fix it once I get some time to look at the code better.
Having conquered the USART, I was assigned to study up of PIC18F67J60, similar family to the PIC18F97J60 that I have been working on so far. I was also looking into the SD card functionality. I was briefed about the expected outcomes from the PICtail’s role in the project and was also brought up to speed about the progress in the SD card functionality codes by my colleague. Having conducted some basic study into its functionality, I was able to develop a simple Read and Write program with some LED indicators about the current state of the process. Further studies into the file structure and the raw data writing into SD cards lie ahead and I’m looking forward to it.
By the end of the week, the butterflies were gone and I made some good friends at work. Sadly, two of them finished their internships and I won’t be seeing them come Monday. I feel blessed to have gotten to know them for even such a short time. I just pray we can still stay in touch. All in all, it was a great first week, where I learned alot and I’m looking forward to Monday and continuing this fascinating internship.