# moyoyoyo

EstablishedMember

28

0 Neutral

• Rank
Regular

2. ## driving two relays with 12c508a

HI, In addition to the fine code that Joan provided may I suggest the following link: http://www1.jaycar.com.au/images_uploaded/relaydrv.pdf This is for the hardware part of things, It tells you how to drive relay with a npn transistor. you don't want to drive a relay directly with you pic. Plus the diode shown will protect you pic from back bfm or what ever that means. I have use this circuit myself and it has work thus far. (knock on wood).
3. ## 8x8 multiplication

Now I have a question on this subject. I though the maximum number a counter or register can have is 255. Are you saying that C2C is smart enought to make the necesarry arangements so that a numbers bigger than 255 can be stored? On a non related subject. When are we going to get a C level debuger?
4. ## 8x8 multiplication

This has been posted for a while now and nobody has answered the question yet. Well, I don't know te answer either. YOu might want to check out this page. It gives you some examples but they are in assembler. http://www.piclist.com/techref/microchip/math/mul/index.htm I haven't tried anything yet but perhaps instead of multiplying you should try ADDING. for example 4x3 is really 4+4+4 So, maybe if you do a special function where it has a few counters. I think everytime there is an over flow there is a carry flag in one of the special register that get set. So you could do 0xff +0xff one time and the check the carry flag. then calle a second function to store a number or something. then add another 0xff so on and so forth. THe point is ytou cannot have a number higher that 255. but you can have many 255 store in different places. then you could have a 3rd function that puts all teh counters together and give you the number you want. THis is just a basic idea of the top ofmy head. I haven't ested this out yet and I'm sure there is a more efficient way of doing this. I hope that if this doesn't help maybe it will give you or somebody more ideas and come up with something. If you solve the problem please post it here so that we can all benefit.
5. ## LCD Plugin is here

cool pluging. now all we need is a c level debuging and we will be all set.
6. ## read out a port

I like joancanet idea but instead of writing 8 different #define staments you could use an array. I don't remember the proper syntax because I'm still learning and I keep going back and forth through my references but the idea is something like this. arrayname[8]= {'0x01', '0x02', '0x04',....} int x=0 int find_bit(0); /* call the find bit function */ . . . find_bit /* function */ { if (arrayname[x] & gpio) /*compare the value in position x*/ /* in the array to gpio */ { varA = x /* store the value of the pin in varA */ return varA /*maybe is return X */ } x=x+1 } I'm pretty sure that the syntax and spelling are wrong but you get the idea. Just call the function whenever you need to find the pin and use the varA (or maybe is x??) to set you port or to do whatever comparison you need.
7. ## oscillating outputs

oops I've been away for so long, I bet by now you must have found a solution to your problem. I'm taking a while guess here but did you make sure that the watch dog timer is off. Are you using the same programer to burn your program and the same software? I don't have my c2c software set up properly. so, what do is convert from C to assembler in c2c. Then I open mplab and convert the assembler into hex. Then I open my programer program and burn the PIC from there. In my programer theres an option to turn off the watchdog timer. I use the EPIC Plus PICmicro Programmer and I had to set 3 different options to disable the watch dog timer. diferent programers have diferent settings and options. I think you can also disable the watchdog timer through software (c2c). Do you have an oscilloscope? this is the most valuable tool you can have. check the frequency of the oscilation then compare thatnumber to the number given in the specs for the watchdog timer. remember to compesate for the clock frequency. If you have mplab which is a free software or picant you can simulate your code. make sure that when you compile the code in C2C it doesn't add something that makes it loop.
8. ## when?

when are we going to get a C level debugger? The assembler level debuger is fine but it creates its own labels and requires learning assembler. I think this is the only feature that this fine product doesn't have and needs.
9. ## oscillating outputs

Could you include the code? it is poible that you have a loop somewhere or you have an error somewhere that makes the code behave as a loop. An example would be when a counter counts past its limit. I think a counters limit is 256. I had a similar problem with an LCD. I used a string to store my mesages. I forgot to add the terminator part. That is, my code kept printing the next character but because it didn't know when to stop it reach a limit and it looped back to another section of my code. May I suggest adding a LED and a 3 second delay. You need visual aids to help trouble shoot things. or try a simple code like pragma# 4000000 set_status(rpx,x1); TRISC 0xXX set_status(rp0,x2); void main (void) { output_high_port_x1( x2 ); /* sets a pin high */ while (1); /* code will lop here forever. the pin set above will stay set forever */ } the while(1); makes the compiler loop on the while comand for infinity. Without it, it is possible that the code will repeat and you will see the on/off problem. you can also use portc=0xaa to set the whole port. The Xs on the code above means you must fill in the blanck with the proper value, depending on the device you are using. One last thing, depending on the device you might have to set some register a certain way. An example are devices that have analog capabilities. On a pic of this nature you must make sure to tell the compiler to set those pins to digital mode, other wise the pic will think that that pin is used for an analog signal. as a disclaimer might code might have some errors in it. I don't have my reference in fromt of me for the proper syntax, but the idea is there.
10. ## How to start?

Hi, I think you and me are on the ame boat. I always wanted to learn C but needed a project for motivation. Did is what I did to learn enough C for my hobby projects. 1.Buy or go to the library and get the C for dummys book. Is an old book but very good. It will cover the basics. C2C doesn't use all the options like printf and what not, but is sure is darn close. 2. Buy the C for PIC micro from matrix multimedea. Is a cd that teaches you how to program specifically for the PIC micro and it uses the C2C compiler. The cd is not the best but is pretty good. Plus, you can always go back and referesnce the sample codes. It also has all the code easily accesible. 3. visit this forum often and ask questions. Hey I'm a newbie too so any help and ideas is welcome in my book. 4. from my side, buy or build a way to debug cause C2C doesn't have a C level debuger. I'm currently building an universal LCD display controler. The idea is to have this circuit dedicated to a LCD and that I can use it on all or most of my projects. Along this line you should build a PIC tester. I made my own and is very simple. all port A are inputs and all portb are outputs (using a 16f84a device). The outputs are conected to LEDs to see what is going on. This way you can test your code. I'm going to build another one so that any pin can be input or output and any pin can be interface with the outside world (external device). I bet you are already seasoned in electronics but just in case let me recomend the following pieces of equipment. A multimeter. You can get one that measures capacitance and it would be nice for one that measures hfp. Power supply, a breadboard. And finaly a 20MHz or above Oscilloscope. I have a 60MHz and it helped me trouble shoot noise problems created my motors and other little nig nags that can be detected with the naked eye. Go to e-bay and get a tektronix. expect to pay \$250 us so, start saving now.
11. ## Two Major Improvements

A C level debug would be nice too!!!
12. ## what is a #pragma?

For the sake of those few unfortunate souls who are not completly inagurated into the C language what is a pragam and how can I sue it? What is that clock pragama that I keep seen?
13. ## warning message meaning

Warning in line 60: Truncation from 16-bit to 8-bit what does this message means and why did I get it? also, should I be concern about it?
14. ## would be nice to have

2 enhancements for picant IDE 1. a generic LCD plugin. both serialy and in parallel. 2. C code source level debuging capability.
15. ## Integration into MPLAB v6

I finally got the answer but its not good news. There is not support for mplab 6.x at the moment, and even if there were, the C level debugger will not work because c2c does not generate this kind of information for the mpalab to work with. What a shame!!! maybe in the near future.
×