Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Reynard

  1. Did you add the libc.pic18.lib to your project. See page 20 of the manual. Cheers Reynard
  2. Hmmmmmmmm! Sounds like a problem I had some time ago with the 12F629 pic using a MikroElectronika EasyPic2 dev board. I could program the device straight from the packet but never erase it again to reprogram. I too thought I had blown them and had a nice pile of these chips that I could not reuse. I eventually tracked the problem down to the supplies not being switched in the correct sequence. The Vdd (+5V) arrived when the USB cable was plugged in, then Vpp to program it. This chip requires the Vdd to be cycled as well as Vpp to reset the device internals. I ended up having to build my own programmer which cycles the supplies in the correct sequences and have had no problems ever since. I use the EasyPic2 for all other pics. Just not the 12F629. My tupence worth Cheers Reynard
  3. This is a debugger problem. Maybe something to do where the GOTO statement was placed in the listing file. i.e. inside the previous 'for' loop. The code works OK though. There is a colon inside your first 'for' loop which I assumed was a typo. Cheers Reynard
  4. void main(void) { asm { clrwdt 0003 0064 CLRWDT } } 0004 0008 RETURN Works for me. What error message are you getting ? Cheers Reynard
  5. Hi Eric, Thanks for the ps2 info, I will have a look at this Microchip code. I compiled the interrupt.asm in the examples directory and the listing file says MPASM 5.14 How you set up argument passing and return values is another thing. Perhaps Dave or Pavel could clear up how to interface to a pure assembly file (.asm). Cheers Reynard
  6. Hi Eric, I done something way back in late 2000 interfacing a ps2 keybaord (101 key I think) to a serial port. I used a 16C558 chip which has no UART so had to bit-bang into 9600 baud. The serial comms worked both ways so I could send reset and led commands to the keyboard for num and shift lock etc. via serial port. I was all done using MPLAB assembler. Ahhh, those were the days. Sigh! The project never came to anything so did not get a chance to put it good use. You may have whetted my whistle to look back on it and rewrite in C. Not that I have a use for it but just for the interest using a more up to date PIC with built in UART. Cheers Reynard
  7. Michael, You did not add: #include <system.h> to your code. As I said, if you want accurate timings set your osccal register otherwise the internal oscillator will run at something 3.8MHz and not the expected 4.0MHz. With SourceBoost C you use lower case for the PIC registers. trisio = 0b00000000; gpio = 0x55; etc. Cheers Reynard
  8. When I use the 12F629, I use something like this for the CONFIG setting. // Configuration byte data. #pragma DATA _CONFIG, _CP_OFF & _WDT_ON & _BODEN_OFF & _PWRTE_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF The bit definitions are in the ..\SourceBoost\include\p12f629.h file. Your code doen't make much sense at the moment. Thw while loop will run very fast then fall off the bottom which will probably jump back to main() again and repeat forever. Yo may also want to set the oscillator calibration byte to get accurate timings. // Install the oscillator calibration value. asm { call 0x3ff ; get calibration value from program memory. movwf _osccal ; put in calibration register. } Cheers Reynard
  9. I assume you are referring to the TSOP1738 type of device for the reciever. It seems like a good device to use. Remember the data rate (baud) will be low but it all depends on what you intend to use it for. It has an ambient light filter but within reason. It is OK for an indoor environment but don't point it directly at a window where bright daylight is going to shine on it. I like using RF devices from RF Solutions which means no line-of-sight problems. Cheers Reynard
  10. Modulating the signal will act like a digital filter allowing only the signal you are interested in being detected and not random interference from anyother IR sources. If you want increased range you can try an array of transmitter diodes to increase IR intensity. Modulation won't help the sunlight problem. Once the photo diode is saturated with sunlight it won't see your signal. There are several chip sets out there which will do the modulation/demodulation for you if you don't want the PIC to do it. A Google search should get you some info on the subject. Cheers Reynard
  11. Hi Dan, Welcome to the world of the PIC and wave goodbye to the Pentium. You could look at the 8051 cored microcontrollers. Keil 8051 compilers are re-entrant but cost a few more bob. Simple stuff like integer add, subtract, shifting and logical operands should be OK to use in interrupts as they don't need to keep intermediate results and loop counters (sometimes). It is always good just to peek at the generated assembly code to see exactly what the compiler has done. Enjoy the PICs versatility and its limitations. Cheers Reynard
  12. I think the answer is no. The PICs (16 & 18 series) have a small stack and probably no instruction that can manipulate it or index into it. Software stacks using RAM space can be created and offered on some compilers. There is of course a performance penalty when using a software stack. I think you can assume that most library functions are not re-entrant because they keep their working variables in global memory allocated by the linker. These memory locations may also be shared by other functions depending on the call tree results. Top end PICs such as DSPs do have a stack pointer and lots of indexing modes where you can create a stack frame and stack base pointer etc. Keep interrupt routines simple and not full of complex math. If you see the stack warning, you know there may be trouble ahead and may have to start disabling interrupts at critical moments. Still no guarantee that you will not corrupt overlaid variables during interrupts. Cheers Reynard
  13. To get good range you need alot of current through your transmiter diode or a diode with a good lens to give you a narrower and more concentrated beam. You can get receiver photo diodes with have a daylight filter built into the lens. They usually look black or dark grey. I have played around with one some time ago and found it was less sensitive to daylight if it was fitted into a dark tube to eliminate alot of the daylight shining onto it. Recess it into the tube a few millimetres. Cheers Reynard
  14. The two registers work together to form a 16 bit register. The 16 bit value is basically a divisor which divides down the oscillator frequency into a baud rate. Table 20-1 gives the folmula for the various configurations and Figure 20-1 gives a perfect example. To get an exact baud rate you must have an oscillator frequency that will divide down exactly (14.7456MHz for example) otherwise there will be a small in baud rate that you may be able to live with. Cheers Reynard
  15. Reynard

    Help File Error?

    ROM data is stored in instruction space which can be 12, 14 or 16 bits wide depending upon the PIC type. Therefore DW is used to store data up to the maximum word size. If you use DATA 0x0200,0x123 you will get DW 0x0123 i.e. you cannot store 8 bit only data in ROM. You must use the entire word size. Cheers Reynard
  16. The DS1302 is not the fastest chip on the block particularly if you are operating your circuit at the lower voltage end. If you have a scope, check that you meet all the setup and hold times etc. for the supply voltage used. Compile using a previous version (pre 6.85) and print out the assembler code for the RTC. Compile using 6.85 and compare the assembler code. BoostC on occasionally puts in some redundant instructions. Maybe some of these redundant instructions have been removed with the latest optimization changes making setup and hold times shorter than before. Cheers Reynard
  17. I suspect that SourceBoost C does not support the extended instruction set so you will have to remove the setting from the config word to stop MPlab grumbling when the hex file is loaded I would think. If you instist on using the extended instruction set, you may have to resort to using C18 non-student version. Cheers Reynard
  18. Can you give any clue to what the error message was and what you changed to cure the error message re-occuring ? Cheers Reynard
  19. Absolutely cac001, you hit the nail on the head. Disable those analogue inputs. I must have had my head in the clouds for not spotting that one. Must be all that global warming stuff. Cheers Reynard
  20. Exactly how have you wired up the LEDs to the port pins. Remember that when reading a port it is the voltage level on the pin that is read and not the value of the output latch. Just because you write a 1 to the outout latch does not mean that you will read back a 1. the logic level will depend on the voltage on the pin which could be less than the required threshold. Setting/resetting individual port bits will perform a read/modify/write instruction which can screw things up if the voltages on the pins do not meet the spec. If this is the case for you, then always use a shadow register for the port outputs. Cheers Reynard
  21. I am no expert but start with simple sequential scanning. When you get it working move onto simultaneous scanning if you really need it. Set SIMSAM = 0. Sequential scanning. Set CHPS = 0. CH0 only. Set ADCSSL bit for the input channels you want. Bits 2 and 3. When you start sampling I assume the chip will sample and convert channel 2, sample and convert channel 3, then reset the done bit. The values should be stored in ADCBUF0 for channel 2 and ADCBUF1 for channel 3. ADCBUFX are read only so don't write to them. Never having used your chip I am only guessing but it is probably how I would begin. Cheers Reynard
  22. You need to get a "Goodies" key sent to you to unlock the LibC sources. I assume it will be sent to you a few days after you have registered BoostC. Could be wrong though ! Cheers Reynard
  23. Here is a snippet from the Wiz-C manual which is more or less what BoostC does.
  24. The help file is poor in its description. If you look at the assembler code that is produced you can see how the eeprom functions work. The eeprom write takes time (8ms max). You will have to provide this delay, poll for write complete or wait for an interrupt to tell you the write is complete. The eeprom_write function only eats shoots and leaves. Check that your programmer does not do some form of bulk erase when programming the device. I think erased data is 0xff. Cheers Reynard
  25. On reset ALL ports are inputs (TRISX = 0xff). Also ALL adc channels are enabled. You will have to set adcon1 = 0x0f if you are not using any analogue inputs. The SS/ is on AN4 (RA5) so maybe causing some problems. Cheers Reynard
  • Create New...