Random Ranting (150) · Gadgets & Tech (15) · Anime & Otaku (11) · Watches & Horology (43) · Movies & TV (6) · Photography (3)


Ads

Latest Posts Recent Comments Comrades


My blog is worth $4,516.32.
How much is your blog worth?


CRC-CCITT on a MCU

Another successful afternoon where I launched Windows XP SP3 inside Parallels Desktop v3.0 for Mac, and connected to my MPLAB ICD2 PIC programmer. Yes, Wow!

I managed to test some of the code I had prepared to run the PIC18F1330 which has 6 PWM outputs, 3 independent. This will be sending the PWM signals to the motor driver, based on the instructions received over the serial link from the robot’s on-board computer.

This is where CRC comes in! The code was compiled under Hi-Tech’s PICC18 STD compiler, which I really like. It also includes routines for serial communications and the ‘direct’ CRC-CCITT method as the look-up table is far to big (and tedious) to squeeze into the available ROM.

I do not want to corner myself this early into the project by using up all the available ROM space just to store the CRC look-up table. It is great that the code is still only occupying less than 20% of available memory!

The ICD2 programmer was then connected and the program was flashed.

Erasing Target Device...
...Erase Succeeded
MPLAB ICD 2 Ready
Blank Checking...
...Program Memory
.. Config Memory
...EEPROM
...User ID Memory
...Blank Check Passed
MPLAB ICD 2 Ready
Programming Target...
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0x1FFF)
Verifying...
...Program Memory
...Verify Succeeded
Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
...Verify Succeeded
...Programming succeeded
08-Jul-2008, 17:20:24

Capacitance from the breadboard was causing issues with the serial connection but I found it to be quite reliable with a baud rate of 19200. This also has an pretty decent error rate considering that the PIC is running on its internal oscillator at 8MHz. If I wanted to, this can be increased to 32MHz via the internal PLL; I will only be trying this in the lab as I believe it would be difficult to obtain 500Hz PWM signals at this frequency. I find it interesting that my calculations have been verified since I can see that the PWM port is running at ~494Hz. Not a bad approximation if you ask me xD

The PIC was connected to a FTDI FT232RL IC which is simply a USB<->RS232 IC and this output was obtained using ‘ZTerm’ which runs in OS X and is the best terminal application IMHO.

To my surprise the CRC code is running extremely quickly, and this is thanks to all the bit shifting (>> and <<’s) operations and a few XORs. Once I get all this kit back to my lab, I will be able to pull out the ’scope and take a closer look at the PWM signals as well.

Next: Test the receive interrupt and send PWM duty cycle ratios to the PIC over the serial connection with CRC error checking of data sent!

Related Posts & Articles

  • CRC-CCITT Addendum…
  • A while back I posted a short article of my work on CRC-16, CRC-CCITT, and CRC-32. Few days ago, Joon posted a comment on this post pointing out a 'typo' in the program output. It should read, ASC...
  • MCU Communication with CRC-CCITT
  • The receive interrupt on the PIC was tested, first with a basic 'echo' routine. This was then later expanded to apply the CRC routine on a single byte of data sent as a 4-byte payload. The '$' symbo...
  • CRC-16, CRC-CCITT, and CRC-32
  • The past 48 hours have been quite a ride. I really should be heading off to sleep, but instead...here I am posting on my blog. I spent the better part of yesterday evening right until around 8-9am...
  • MARV Update…
  • I hit a serious problem earlier on in the day. I had failed to notice that the PWM5 port on the 18F1330 was sharing the PGD pin and as such after each flashing of the MCU, the 3rd motor would not fun...

2 Comments »

  1. Mehmet said,

    July 8, 2008 @ 20:25

    Thank you…!

  2. Recent URLs tagged Crc - Urlrecorder said,

    October 20, 2008 @ 4:01

    [...] Recent public urls tagged “crc” → CRC-CCITT on a MCU [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment


Google Search


RSS/Meta Articles