Bunch of questions regarding PIC, PCB fabrication, LCD interfacing and PIC-C

Status
Not open for further replies.

xieliwei

Member
Bunch of questions regarding PIC, PCB fabrication, LCD interfacing and CCS-C

Hello all!

After a while off exploring PICs and stuff (i.e. preparing for examinations), I finally managed to get back to exploring and I have finally got serial communications working.

Now, my first project to get me acquainted to PICs, hardware design and CCS-C is to toggle an LED at a specified interval. To spice things up, control of the time interval is done through serial connected to a PC.

(1.1)The first problem I have is that there appears to be no scanf() in CCS-C due to complexity issues, I have to resort to using getch 4 times to read in a 4 digit number and assume that what I receive is correct (well, I can do boundary checking, but the code gets very heavy). Is there a way to implement something like scanf()? I only need to receive a number (any size within the allowed range, if possible) terminated by a CRLF.

(1.2)The next problem I have is that CCS-C does not give me proper newlines during printf(). I've tried \n, \n\r and \r\n but at best my terminal only gives me a newline but no carriage return.
{Solved} Mysteriously fixed with (1.3), using \r\n.

(1.3)The third problem is one that is a show stopper. The PIC will randomly lock up (the LED will stay on or off, even after multiple intervals have passed). I have no debugging methods other than printf() statements after every line, but that does not tell me much as the lock ups happen at random places.
{Solved} Appears I had a bad supply that couldn't supply enough current.

Those are more or less the problems I have with regards to my little learning project.

Now, on to other questions I have regarding other stuff.

Crystal oscillator
(2.1)Firstly, I'm using a bootloader (SparkFun's bloader, TinyBld strangely does not work for me), which makes code changes fast and easy. I would like to try using an external crystal however and I could only find a 10MHz crystal around my area. I can't find any bootloader firmware for the 16f88 which runs at 10MHz and I do not know enough assembly to attempt to change things myself. Would someone be nice enough to walk me through this?

(2.2)Secondly, what is the significance of the resonance mode used to generate the frequency of a crystal? Is there a difference between a crystal oscillating at 4MHz at its fundamental frequency compared to that oscillating at the same frequency at its 2nd overtone for example?

(2.3)Thirdly, what is the difference between a normal and a TH crystal oscillator? What is TH anyway?

LCD interfacing
(3.1)I have a 44780-compatible LCD display which I wish to interface with the 16f88. CCS-C seems to have a LCD driver for this PIC but I do not know how to use it, anyone care to explain how I can use it?
{Solved} Playing around with different settings, I finally managed to see how the PICC LCD driver works.

(3.2)In case the 16f88 is not suitable (I think it may not have enough pins), which PIC would you recommend? I do have a 16f887, but I have problems using it, see below)
{Solved} There's a nice list here documenting the supported devices CCS-C supports along with their respective hardware capabilities.

(3.3)NewWhen using lcd_putc() (which basically sends the required byte to the LCD in data mode), there appears to be an auto warp feature. However, it seems that the auto warp occurs at a boundary past the size of my LCD; I place 16 characters onto the screen, I expect the 17th character to appear on the second line, however, the 17th onwards characters do not appear, only the 41st onwards characters appear on the second line. The same thing happens for the second line warping to the first. My question is, is there supposed to be an auto warp feature or am I just causing some memory overflow or I have a badly implemented LCD module?
{Solved}:


PIC16F887
(4.1)I have a third party PIC programmer that does not support the 16f887, but it does support the 16f877 which microchip says should be code portable with the 887. I know code portability does not mean programming portability, but I tried anyway (the actual code is of course written for the 887, I'm just programming it with my programmer set to the 877 mode), but it didn't work. Can anyone help?

(4.2)Any way to build a cheap ICD compatible debugger/programmer? I am paying everything I'm doing through my own allowance (which is barely enough to survive with) and my studies really don't allow me enough time for work (and indeed experimenting with PICs).

PCB Fabrication
(5.1)Are there any dirt cheap PCB fabrication services out there? Even for prototyping services, the cost to set up a job is already half of my monthly allowance, not counting the actual board cost and S&H. I prefer not to do etching and stuff since I'll be dealing with SMT components as small as QFN and traces that are exactly 6mils wide and apart (yes, I'm really packing things to the limits).

External Memory Interfacing
(6.1)I'm thinking of learning how to interface external memory into my PIC. I have two types of memory available to me. Both are NVSRAM, but one is 1-wire based and the other is parallel. I want to try them both. Anyone have any idea how I can set each of them up? Are there pre-made functions that I can use in CCS C or must I write my own?

(6.2)My final goal in the end requires a very large code base. Is it possible to store part of the program in PIC and the other parts in NVSRAM? If so, how can I "flash" the NVSRAM?

I have many more questions dying to be answered, but I guess I have asked enough for one post.

Your help will be deeply appreciated!

(I have labelled each question in brackets so as to make referencing easier; please quote the question number when answering, it make things clearer, thanks)

(I noticed that I've been confusing CCS-C and PIC-C all along, to clarify, I'm currently using CCS-C)

(I have decided to use this thread as a sort of log of my progress in learning PIC, hopefully someone in the future who goes through the same journey as I have would find this useful. Also, it'll prevent me from flooding the forum with threads.)

(Apparently I am too busy with school on weekdays, so I'll be unable to check the threads on these days.)
 
Last edited:
Try running your code in the MPLAB simulator.

Bill has the schematic for his ICD2 clone the Inchworm at https://www.blueroomelectronics.com. For the most part it is a 16F877(A) and a few transistors. That will program most 5V parts and provide for In Circuit Debug. His Junebug is a faster USB programmer but the parts are more expinsive and you may not be able to program the 18F with your current programmer.

Fill in your location if you do not mind.
 
MPLAB simulator eh... Good idea, shall try that. I have a bad feeling that its more of my hardware setup than software issues though.

I have looked at his eBay shop and asked him some questions regarding these. Looks interesting. I'm (like many others) also unsure of whether the inchworm+ or junebug is better as I happen to have some projects planned that will require dsPICs and I'm not sure if the junebug PICKit2 clone can program it.

The unicorn also looks so useful... Oh money...

I've checked my current programmer's compatibility list though and it seems like it supports the 18F2550 used in the junebug, so I won't have any problems building/upgrading it.

Location as in Country? I live in Singapore.

Thanks!
 
The Junebug can program the 5V dsPICs (30F) and with a couple of diode clamps the 3.3V PICs too (provided they have their own power supply) See the beta manual on the Junebug page for details. The dsPIC30F4013 is very popular (Junebug can program but not yet debug most dsPICs) If you can't wait there is a 24FJ16GA002 that has both debug & program support as of MPLAB 8.02

You can hook up an LCD to the Junebug as other posters here have found using the USER connector but the Unicorn makes it easy as it's LCD ready.
 
To 3v0: I just tried MPLAB SIM today. Couldn't do much as the UART simulator does not allow human inputs, and I couldn't write a proper input file to get it to work.

To Bill: I'm tied between getting the Junebug, Inchworm+ or Unicorn, I'll need some time to think about it.

To mneary: Thanks for the suggestion, I have updated my profile.
 
The LCD is basically a 2x40 controller hooked to a 2x16 LCD, they're made like this so you can use the exact same controller with multiple LCDs. This is why you line wrap after the 40th character, usually we issue a command to tell the LCD to go to the second line.
 
I'd recommend the Junebug. It's just so feature packed, USB & less futzing than the Inchworm+ Unicorn combo. Some folks get the Junebug & Unicorn and use it as an LCD kit, I sell more for that use than Inchworm+ upgrades.
 
Hey all.

Thanks for the simple and clear response, Norlin!

I guess I'll need to hold my need to purchase a new programmer for a while as I just drained all my money on something. But, I'll really be getting a Junebug as soon as I have enough money.

Thanks!
 
Hello people.

Sorry that I have disappeared again, down with some nasty illness.

Anyway, I'm learning how to interface external memory to a PIC, so I've added some questions above, please help!

(I'm also hoping some of my other questions cna be answered too, very much appreciated!)

Thanks! =)
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…