PIC speed problems


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ok, ill have a look around for it. Im using a 20MHz oscillator already. The baud rate for the serial data is 115200. I would have thought that uses more processing power but i did have this working earlier. The problem seems to be with the code between the serial data arriving and the LEDs being turned on. Im still cutting as much out as possible but theres a limit to how small a program can be before it doesnt do everything you want. Ill probs strip my program back to basics when i test out that software PWM thing then build it up a few lines at a time.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    You're using an 'F87, I used an 'F628A. 15 I/O pins available for me, 2 used for 20Mhz crystal, 2 used for Serial I/O, PGM/MCLR tied as needed, 3 buttons and 6 LEDs (2 RGB), and one spare pin. I was able to do serial at 19,200 without a problem using the hardware module (datasheet says it's 1.7% high, but it worked). Used Timer0 kicking an overflow interrupt at 19.531khz, software PWM for each LED at 76.2Hz, 8 bit resolution. Could get a higher refresh rate at the expense of resolution. Once in a great while, I'd get a slight bit of one-time flicker if I was trying to receive serial data too fast or send it too fast, but that's completely up to the software driving it.
    I think that 'looping' PWM will end up kicking your butt in the long run, but that's just me.
    Time to learn how to use interrupts to your advantage!

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I found that PWM thing. Took a bit to get it working (installing MPASM etc) but i figured all that out. The problem i have is that for some reason the serial interrupt, PIR1.5, never equals 1. Im not sure whats wrong. At first i thought maybe the loop wasnt running but i added code to increase/decrease the PWM value and it worked fine. Its just that interrupt that doesnt seem to work. Im guessing its got something to do with the timer interrupt overriding it or something.

    Edit: Im not using ON INTERRUPT. Aparently that doesnt work. Im only checking for PIR1.5
    Last edited by The Master; - 5th October 2008 at 22:40.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Edit: Im not using ON INTERRUPT. Aparently that doesnt work. Im only checking for PIR1.5
    I'm using the ON INTERRUPT in that particular program I eluded to earlier. Works fine for me. It's definitely not optimal like the Instant Interrupt's, but it works and it would take too much rework to change it over.

    If you're serial isn't working, get rid of the PWM for awhile and just turn things on/off to show that the serial port is in fact working (or not). Again, break it up...then put it back together...

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    The serial was working fine before and still does work with test programs. It only stops working when i add the PWM code. I tried adding the PWM code to an existing program that i know works. The PWM works fine but stops the serial from working. I also tried a brand new program starting with just the PWM and adding serial but with the same results.

    I cant seem to send data while the PWM code is in either. Its like its overriding the settings for things like continuous receive etc and disabling serial.

    Would it be worth trying to write code to use the timer similar to this PWM code but writing it in PBP instead of ASM? I dont understand ASM at all so when something goes wrong i have no idea how to fix it. Is there something like PIR1.5 but for the timer instead? Would that work or would it run too slow?

    Edit: I have some code to turn a status LED on for about half a second whenever PIR1.5 equals 1 regardless of the data i get from RCREG. Always works without PWM but never works with it. I also had a blank project with only PWM and some simple serial receive code that copies RCREG directly to one of the PWM values but still no luck
    Last edited by The Master; - 6th October 2008 at 00:24.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, just to be on the same page here...
    When you say 'PWM' code, what do you mean exactly?
    Something tells me that you're using the 'PWM' command and not the hardware, or even an interrupt based PWM method...

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Im using a pbp project that i downloaded from the net. Its written by Darrel and you use it as an include file. I got it from here http://www.pbpgroup.com/modules/wfse...p?articleid=12. Where i said "PWM code" i should have said "Multi_SPWM.pbp and the few lines you have to add to make it work"

    On that page Darrel said "There's no way to combine Basic Language (A.K.A. ON INTERRUPT GOTO) type interrupts, with ASM interrupts". Does that include PIR1.5 then?

Similar Threads

  1. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 01:52
  2. Pic Vrs Atmel speed
    By shawn in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2008, 22:50
  3. Replies: 14
    Last Post: - 26th September 2007, 06:41
  4. IC2 pic 18f452 program problems
    By MrSafe in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 20th September 2007, 19:55
  5. Help, problems first time with 18F452 PIC
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2005, 21:49

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts