CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic24fj128ga202 uart issues. [Solved]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
smee



Joined: 16 Jan 2014
Posts: 24

View user's profile Send private message

pic24fj128ga202 uart issues. [Solved]
PostPosted: Fri Jan 22, 2021 11:07 am     Reply with quote

Hello, hoping someone can throw me a few suggestions, as i am being tortured by this PIC.

I am using MPLAB 8.92, PCD 5.080.

I don't seem to be able to get the uart to transmit on port PIN_B6 (RP6).
I am using the sdip 28 pin package.

I am trying to talk to a vdrive2. PIC is 3.3v and vdrive2 is 5v.

CTS is on PIN_B5 - and it works correctly.
RTS is on PIN_B7 - and works correctly.
RXD is on PIN_B8 - and works correctly.
TXD is on PIN_B6 - and refuses to work correctly.
I can turn PIN_B6 high and low with output_high/low functions.

RXD and CTS both have pullups to 5v via 4k7, and have set open collector at the PIC end.

But i can't get the uart to toggle the line.
I have tried 2 different chips, both the same.

I don't have a simple program, will do tomorrow.
Any suggestions?


Last edited by smee on Sun Jan 24, 2021 3:00 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 22, 2021 11:53 am     Reply with quote

this ...
Quote:
PIC is 3.3v and vdrive2 is 5v.

is a huge 'red flag'.....
Look at the Vdrive2 specs for what an incoming '1' is....
Ttelmah



Joined: 11 Mar 2010
Posts: 19561

View user's profile Send private message

PostPosted: Fri Jan 22, 2021 12:46 pm     Reply with quote

Understand that the 'open collector' option does not allow the voltage
to go very much above the PIC's supply. It is not designed to allow you
to drive a signal requiring a higher voltage, it is designed to allow wires
to be 'wire ored' together.
The output float option only acts between bytes when using the UART.
To drive the VDRIVE with a 3.3v PIC, you need a 3v to 5v interface for
the TX (and the output handshakes if you use them), and a resistot
divider to feed the signals the other way. Simple 3v to 5v circuit is:

https://www.gadgetronicx.com/logic-level-converter-5v-3-3v/

Or a 5v logic gate with a low Vih specification.
smee



Joined: 16 Jan 2014
Posts: 24

View user's profile Send private message

PostPosted: Sat Jan 23, 2021 5:25 am     Reply with quote

This chip has some serious issues if you ask me, avoid it if you can.
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Sat Jan 23, 2021 8:30 am     Reply with quote

smee wrote:
This chip has some serious issues if you ask me, avoid it if you can.

This is surprising to me. That's the same family of chip they use on their Curiosity dev boards.
Ttelmah



Joined: 11 Mar 2010
Posts: 19561

View user's profile Send private message

PostPosted: Sat Jan 23, 2021 12:01 pm     Reply with quote

I think he wants to 'blame the chip', for his own incompetence in not
realising he needs proper circitry to adapt a 5v device to use with a
3.3v chip. I;ve used this chip and it works well.
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Sat Jan 23, 2021 12:16 pm     Reply with quote

The PIC24FJ128GA204 is my go to when I want to test out some new parts because it comes on the curiosity board, with a header for the mikroe click boards.
dyeatman



Joined: 06 Sep 2003
Posts: 1938
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jan 23, 2021 1:25 pm     Reply with quote

I have used the '204 and '206 numerous times with no problems.
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 23, 2021 2:34 pm     Reply with quote

Maybe it's time ( past due ??) to add a 'sticky' on how to properly interface 3 V PICs to 5 volt peripherals ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19561

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 1:14 am     Reply with quote

The answer is the same as for the SD card sticky already there.
(going the other way).
However a more generic one brought a little more up to date, might
well be worth generating.
smee



Joined: 16 Jan 2014
Posts: 24

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 2:50 am     Reply with quote

hi guys,
I solved my problem by swapping my rts and txd pins over,
and it now works as required.

My issue was that the uart could not control the pin.
I had tried uart1,uart2,uart4 all with the same issue on PIN_B6.
Moving over to PIN_B7 made it work as required.
It seemed odd that PIN_B6 would not work.
I hunted around and found that a few people have had issues with
differing modules of the pic24fj128ga202.

Uart issues here
https://electronics.stackexchange.com/questions/192824/pic24fj128ga202-uart2-and-uart3-not-working

and again uart issues and port rb4.

https://electronics.stackexchange.com/questions/211679/pic24fj128ga202-some-i-o-portb-pins-not-behaving-correctly

Another with uart issues
https://www.microchip.com/forums/m910808.aspx

uart issues again
https://electronics.stackexchange.com/questions/208408/rs485-not-working-in-pic24fj128ga202


The common thread with these issues and also with my problem was PIN_B6/RP6.
Then i found this one,
this one finds issues with output compare, uart and other output compare, and actually gets to the bottom of the issue.

https://www.microchip.com/forums/m961027.aspx

At the end of this one it says...

Got the resolution proposal in the tech support system.
I think this is OK as long as CW2 bit 11 is documented in data sheets with
"needs to be programmed for RP6 to function correctly".

It seems that RP6 will not work with PPS modules unless this bit is set.
And as RP6 is one of the few pins that are 5v tolerant, it's an important pin.

I haven't tried this CW2 bit 11 setting, as like i said i shuffled my pins around.

I also had another couple of issues with this chip.
PIN_A4 and PIN_B4, I had to abandon trying to use them as i just couldn't get them to work.
I am using mplab8.92 and ICD3, and the support for the 24fj128ga202 is beta support in mplab8.92.
They are supposed to be inputs according to the datasheet but the Tris bit
is fixed at '0' and they will not do as they are supposed.
I had the OSCIO and SOSC_DIG setting on.

And like RP6 they are 5v tolerant pins so quite important pins.
smee



Joined: 16 Jan 2014
Posts: 24

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 2:58 am     Reply with quote

Maybe it's time ( past due ??) to add a 'sticky' on how to read the first post Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19561

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 4:37 am     Reply with quote

Maybe (more to the point), it is important to actually be correct in what you
write in your first post.

You said that RTS and CTS were both 'working correctly', but in fact the
issue was that the PIC was not being sent a low on CTS, so (of course),
would not send anything.... Sad
A simple test on the board would have shown this wasn't low.

The VDRIVE, though as a module it has a 5v supply, is actually internally
a 3.3v device (check the VNC1 datasheet), so you don't have signalling issues.
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 5:43 am     Reply with quote

re: The VDRIVE, though as a module it has a 5v supply, is actually internally
a 3.3v device (check the VNC1 datasheet)

hmm, I never really thought about that, but of course makes sense. I'd always considered it 5v as it plugs into a USB slot. Got me wondering if there's a 3v version...though it's have to be 'flash drive' compatible...

going to be even more 'fun' when 1.5v becomes the new peripheral standard.....
smee



Joined: 16 Jan 2014
Posts: 24

View user's profile Send private message

PostPosted: Sun Jan 24, 2021 6:02 am     Reply with quote

this doesnt really serve anyone, but for completeness.

the cts and rts lines did work correctly.
pulling the cts line low by the pic caused
the rts line to be subsequently pulled low,by the vdrive.

and once that had happened rs232 transmission would
also occur, identifying the vdrive, and stopping the
three red flashes.

inserting a usb drive, would also cause more transmissions.

this was all observed by the 4 channell dso attached to the lines.

what didnt happen was the transmission of commands to the vdrive
on the txd pin ( PIN_B6 / RP6 ).

the level of the rts/cts lines didnt matter to my driver at that time.
it would just transmit whatever was in the queue.
that was as uart4, so i recoded to use uart2- same outcome.
uart1 runs rs485 comms, so i changed the pin_select on uart 1 to use
pin_b6, again nothing. and i knew the uart1 was all ok.

spent ages checking registers pps,etc, all were correct as far as i could tell.

changed chip to a new one, put a fputc in an a forever while loop,
so that i should see a stream of back to back 'E' on the transmit pin.
still nothing on the pin, checked transmit buffers/registers -all empty and waiting.
checked that the pin could be toggled with output_low/high - that worked.

changed the pin from b6 to b7, and that fixed it, everything worked on b7.

i had already,had to abandon using pins A4,B4.
B4 had been the rxd pin originally and A4 the rts input but that didnt work either.

i suspect the A4,B4 problems are similar to the B6 issue, but i dont need them at the moment.

this pic is peculiar.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group