Jump to content

jknickel

EstablishedMember
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

0 Neutral

About jknickel

  • Rank
    Newbrie
  • Birthday 03/04/1971

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    South Africa
  • Interests
    Model Aircraft and flying
  1. I have a main PIC 16F767 processor and a few other slave processors doing other tasks like a tachometer. I want to use the SPI bus to talk to these other slave processors, but I am having trouble getting the data from the tachometer. I use the same code on both processors as shown in the attached files, the one is a master, the other slave, but it seems to get stuck waiting for the slave to respond. I only have one ICD2, so I can't check what is happening on both processors. Any ideas, or other code I can use to communicate between the processors would be appreciated. Regards Jeff spi.c spi.h
  2. I am having a similar kind of problem. I am building a telemetry system for model aircraft, which sends data down to the ground using a Radio modem. The data is sent on a timer interrupt, with some analogue inputs, and a GPS receiver. I am using the PIC16F767, and lately changed to PIC16F886. The GPS strings are stripped and only the required info is used. I have a static transmit buffer, which has fixed header information, except for a packet counter, and the variables are unpdated in the main loop, and the data is sent using the TX interrupt till the buffer is complete. The problem I experienced is that some of the data seems to get corrupted. I use a TX busy flag to stop the buffer being updated during the data transmission. To speed up processing, I wanted to just update the variables, but it turns out that it is only valid for the first iteration, there after they are garbage. To get around this, I have to rewrite the buffer before sending it. I don't know if this is a problem, but each module is contained in a separate file, e.g. GPS processing, analogue inputs, serial transmittting and packetising. I had thought of putting all the buffers in the main program, and just pass pointers to them, or do the transmission of the data in the main loop, with just a flag to start the transmission. I had to increase the processor speed to 8MHz to cope with the GPS processing. There was quite a bit of footwork to process the GPS strings without storing the entire string in memory. I am using MPLAB 8.0 IDE with the ICD2 for programming and debugging.
  3. I get the warning message when I use the adc_measure function. I have set the CLOCK_FREQ pragma, I am using the internal RC oscillator which runs at 4MHz on the 12F675. I can't even get the delay_us to work at this frequency, I have to use a few nop instructions for those delays.
  4. I have been trying a work around for ADC problem I have, and when I use the delay_us macro, it fails to create it. I have set the CLOCK_FREQ pragma to 4000000 but the linker fails to generate the code for it. I get this error: I also get this when I use the adc_measure function How can I tell if it's generating the delay loop correctly?
  5. Hi I seem to be having trouble using the 4 ADC channels on the PIC12F675. I am using it for a gyro sensor for model helicopters. I have 4 analogue inputs, gyro sensor, gyro reference, temperature and gain potentiometer. All these are referenced to the 5V supply. When I measure the potentiometer on channel 2, there is no change in the values when changing the potentiometer, and I measure with a multimeter, that in fact the voltage is changing. I seem to be getting the same value from all the channels. I am using the adc_measure library function to get the ADC value. It works great for the gyro sensor input on channel 0, the temperature is on channel 1 which doesn't change much in the lab, unless I use a hair dryer or heat gun. This is how the PIC is configured. void InitialisePIC() { // Switch off the comparator cmcon = 0x07; // Set the port direction trisio = 0x3F; // The servo is an output clear_bit( trisio, SERVO ); // Clear the GPIO register gpio = 0; // Switch on the weak pull-ups on the servo output wpu = (1 << SERVO); // Setup the ADC input channels, Clock source is Fclk/8 ansel = (1 << ADCS0) | (1 << GYRO_CHAN) | (1 << GAIN_CHAN) | (1 << TEMP_CHAN); // Right aligned data, and turn the ADC on adcon0 = (1 << ADFM) | (1 << ADON); // Use timer 1 with divide by Fosc/1 t1con = 0x00; // Set the timer 0 to 1:256 ratio option_reg = 0x07; } This is the code to get the gain pot value, GAIN_CHAN = 2 in this case. char Get_Gain_Pot() { short retval; // Get the gain pot value retval = adc_measure( GAIN_CHAN ); // Reduce the sensitivity retval = retval >> 2; return (char)retval; }
  6. Hi Dave short[ NUM_TIMERS ] TimerVal; short[ NUM_TIMERS ] TimerPreset; My silly mistake (above). I have been writing a lot of C# code for the PC application which does things a little different. This is what itr should have been. short TimerVal[ NUM_TIMERS ]; short TimerPreset[ NUM_TIMERS ]; This is where the function pointer would be useful, to execute a function on timer expire. Regards Jeff
  7. It would be very useful for my projects to have arrays of integers. This still seems to be a problem with BoostC and C2C compilers.
  8. Hi I am busy writing some code to run certain functions at the end of the timer interrupt. I want to send or read data at particular intervals, but I want call a function, any function, at these intervals. How do I setup and call function pointers in BoostC? I haven't found any examples yet. Regards Jeff
  9. Will there be a port for the dsPIC range of processors soon. I have an idea to use one as a controller for my current project. Jeff
  10. It has been discovered that the 16F7x7 series microcontrollers have a problem when using the ICD. There needs to be a NOP inserted at memory location 0x0000 to allow the debugger to start properly. There is a description of this problem on the Microchip support forum. It would be nice to have the option when compiling for the ICD to automatically insert this NOP instead of using the work around described in another one of my posts. See: http://forum.sourceboost.com/index.php?showtopic=1885 Regards Jeff
  11. Hi Dave This solution did the trick. It now works as advertised. The tech support people at Microchip say the HITECH compiler has an option to compile for the ICD which automatically inserts the required NOP at address 0x0000. This might be a good option to add to the compiler and SourceBoost IDE. Regards Jeff
  12. I am using the 16F737 in a model aircraft controller project, and I am battling to get it to run in debug mode. I am using the MPLAB IDE with the BoostC compiler for the PIC16 series. I find the integration with the ICD 2 quite nice with MPLAB. This way I can debug my code easily. According to the Microship website you need to add a NOP after the ORG 0x0000 instruction. It is not clear whether this needs to happen at address 0x0000 or 0x0001. This problem is only evident when the clock speed exceeds 4MHz, mine is running at 16MHz with an external oscillator. I have submitted a webticket to Microchip to clarify this. I can insert a NOP using the #pragma DATA 0x0001, 0x0000 // NOP opcode. I still need to test this. If I add the NOP at address 0x0000, then there is no GOTO start of code instruction is not created, which is a problem, just the NOP is created.
  13. It does for a very long time already. Why you think integer arrays are not supported? The compiler complains about anything other than char type arrays. I would like "unsigned short" or "int" types for a three of the projects I am working on i.e. 16-bit value arrays. I am sure larger numbers would also be useful in some cases. I am implementing filters on 16-bit numbers. Regards Jeff PS I found that the 12F6xx is supported, for some reason it only showed the 16F series in the target list.
  14. I would also like to see support for integer arrays. A definate must for most of my projects.
  15. I just recently bought the c2c compiler and I think this is good product. I would like to see support for other devices, like the 18FXXX and 12F627/675. Particularly the 12F675 which I am currently using in a few projects.
×
×
  • Create New...