Skip to main content
Topic: Still learning PICS (Read 4582 times) previous topic - next topic

Still learning PICS

Hey guys. Im still teaching myself PICs and I am having a small issue. im using an PIC24FJ16GA002; heres the issue:

iv been playing with clocking and peripherals. This specific PIC has two on-board silica UART's.

32Mhz / 16MIPS / Internal OSC with PPL CLK

UART1 = 256000 BAUD
TX -GOOD
RX -GOOD
RX INTERRUPT -GOOD

UART2 = 4800 BAUD
TX - GOOD
RX -FAIL
RX INTERRUPT -FAIL

Now the annoying part is I am using the same exact code for UART1; on UART2. Just a different baud rate. I tried moving the PPS; I tried using both my BPv3 and BPv4; I also tried hitting some breakpoints and checking to see if the the U@ registers had data in it; or if the 'data ready' bit is set but im getting nothing. Now remember; UART1 works great, not a problem...

I attached the sources (not support.c or support.h that just holds a couple misc functions like my delay functions and so on...). Some of the stuff might be off thats only because I have been trying to tweak it to work.

[attachment=3][attachment=2][attachment=1][attachment=0]

So if any PIC guys have a free moment and wouldn't mind looking over my code; I would appreciate it.

Re: Still learning PICS

Reply #1
There are invalid ascii characters (0x96) in uart.h at the BRG calculation defines. Maybe they interfere?

Re: Still learning PICS

Reply #2
Oh I didnt even notice; to be honest I have just been using set BRG values. The source isnt using the calculation; so its #if'd out so its not being compiled or used in any.

:( Any other ideas?

Re: Still learning PICS

Reply #3
No one has any ideas? perhaps a bad pin or somthing?

edit: Wait.. Somthing isnt right here... This is how the config was:

My custom USBASP UART to USB device was on UART1
My BP(s) (both) had been on UART2

UART1 worked perfect; I could read (from PIC to BP) on UART2 just fine; but could not send... I decided to swap the devices; so I put the USBASP device on UART2; and bingo everything on UART2 is working fine... So I decide; I had been doing developing on my BP's so perhaps I jammed up UART; so I flashed the latest public release onto the BPv4 and tried on UART2 again... Now what is happening is whenever I try to send to the PIC; the BP freeze's and I have to reset it. So; I tried connecting the USBASP TX to UART2's RX, and BP's RX to the UART2 TX...

The BP was reading fine; but when I sent a char to UART2 via USBASP; bang the BP freezes again!...

Any ideas on why my BP's are doing that? Its really strange.. I have used UART with my BP's 100s of times so I dont understand why this is causing it to jam up like it is!

Re: Still learning PICS

Reply #4
Hey Brent,

I'm really not sure. the UART shouldn't have any means to freeze the Bus Pirate at all. Do you have any source or anything I can use to test it under debug? What I would want to do is run the Bus Pirate v3 firmware under debug, send the UART data that freezes it, and then see where the Bus Pirate ends up.

Also - this happens on v3 and v4? If it was only one I would suggest you look at the errata for the PIC, but if it is both... probably not.
Got a question? Please ask in the forum for the fastest answers.

Re: Still learning PICS

Reply #5
Have you tried the code without enabling interrupts ?

Re: Still learning PICS

Reply #6
-Robots
I have not, ill give that a try.

-Ian
Thats a good idea; I think I will try that, running the BP in debug that is.

when I get home. Its really weird; the BP just freezes, the PIC keeps going and both UARTs still work; without the BP..

Tested in debug mode; the BP freezes on USB interrupt (see the bus pirate forum -> silly uart problem thread for more details). I used the BPv3 (which doesnt freeze, just doesnt do anything although OLS says its sending) on yet anouther pin (3rd PPS move) and now its working perfectly with my modded USBASP UART-USB tool and my BPv3.

I didnt try using BPv4 with the changes though mabye before I goto bed I will try that, might be a HUGE clue as to whats wrong with the USB deal if it does start working.. such as perhaps response...

EDIT: I tried my BPv4 again; same thing. it crashes when I try to send to UART1.

on a good note; my autobaud detection (no known char needed ;) still works like beauty :D

Code: [Select]
Select output type:
 1. Open drain (H=Hi-Z, L=GND)
 2. Normal (H=3.3V, L=GND)

(1)>

Waiting activity...

Calculated:    5092 bps

Estimated:      4800 bps

Ready
UART>

edit2: mods please delete this thread. the issue is BPv4 usb interrupt handing; it has nothing todo with my PIC testing at all..

even if the BP disconnected from my everything 100% (ecept usb of course); sending data via a secondary USB device to anything causes the BP to freeze. For whatever reason any usb activity causes the BPv4 to lockup. more details and the new thread are located viewtopic.php?f=4&t=3860&p=38963#p38963

this thread is no longer needed.

Re: Still learning PICS

Reply #7
hi guys, im new here and this is my first post, i really want to learn PIC... but im confuse how to start.

Re: Still learning PICS

Reply #8
I reccomend getting a pickit; I have a pickit2 i got from ebay for like 30 bucks. Its a great little programmer that supports all the popular pics; and has debugging support which IMHO is priceless for learning.

Then just start like everyone else; sample yourself a few PICs and start blinking some LEDs.