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!![Big Grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
(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.)
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}:
Norlin said: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.
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: