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 support@ccsinfo.com

rs232 on PIC12F1840 not working SOLVED
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 6:54 pm     Reply with quote

Can you tell us your test procedure ?
What equipment is connected to your board ?
What software are you running (if any) to test your board ?

Give us a list of what you do to test it, so that we can do the same thing.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 26, 2020 8:27 pm     Reply with quote

Hi

I have a program I made 6 years ago with PIC16F1847 that the rs232 is working. Can't test it now as I need to connect keyboard and AC motor.
The .LST is like that:
Code:
.................... #use delay(internal=32M)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,stream=PORT1,errors)
*
0056:  BTFSS  PIR1.TXIF
0057:  GOTO   056
0058:  MOVLB  03
0059:  MOVWF  TXREG
005A:  MOVLB  00
005B:  RETURN
*
00B6:  BTFSS  PIR1.RCIF
00B7:  GOTO   0B6
00B8:  MOVLB  03
00B9:  MOVF   RCSTA,W
00BA:  MOVLB  00
00BB:  MOVWF  rs232_errors
00BC:  MOVLB  03
00BD:  MOVF   RCREG,W
00BE:  MOVWF  @78
00BF:  MOVLB  00
00C0:  BTFSS  rs232_errors.1
00C1:  GOTO   0C5
00C2:  MOVLB  03
00C3:  BCF    RCSTA.CREN
00C4:  BSF    RCSTA.CREN
00C5:  MOVLB  00
00C6:  RETURN


What I see that in this program have two additional lines in in the TX:
Code:
005A:  MOVLB  00
005B:  RETURN

and one in the RX:
Code:
00C6:  RETURN

Maybe this gives a clue?

Best wishes
Joe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 8:33 pm     Reply with quote

A clue about what ? I still don't know what you are doing to test program.
Are you just looking for the LED to flash ? Are you testing the serial ? ]
What makes you think the program fails. List your criteria.

If you are testing the serial, then post what terminal program you are
using on your PC, and post what characters or other data that you are
sending to your board.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 26, 2020 8:56 pm     Reply with quote

Sorry PCM Programmer, I didn't see your post before posting my last post.

The only thing connected to the boards are the LED, the TTL to USB cable (FTDI) and 5 VDC power supply.
The same ICD U64 programmer for all.
I have two laptops and testing with both.
I have the YAT terminal, works OK with the PIC18F26K22 as I mentioned before. I am working with YAT long time already.
Tested also with a very old very basic terminal, I have same results.
I am testing with the posted programs from my post before your last post with all 3 programs, they compiles and blink the LED with correct timing.

The test procedure:
* Connecting the TTL to USB cable to the board.
* Opening the YAT terminal.
* Connecting the power supply while OFF.
* Turning ON the power supply.
* Reading the default byte (0x0A) sent by the board (or attempting to read in the case of the 1840 & 1847) every 2 seconds.
* Sending one byte and get back data+1 (in the case of the 26K22). Repeating the send/receive a few times.
The byte I am sending is 0x55 or 0x44 or 0x33, getting back 0x56 or 0x45 or 0x34.

Hope it helps to help me
Best wishes
Joe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 27, 2020 3:25 am     Reply with quote

gjs_rsdi wrote:

with all 3 programs, they compiles and blink the LED with correct timing.

* Reading the default byte (0x0A) sent by the board (or attempting
to read in the case of the 1840 & 1847) every 2 seconds.
* Sending one byte and get back data+1 (in the case of the 26K22).
Repeating the send/receive a few times.
The byte I am sending is 0x55 or 0x44 or 0x33, getting back 0x56 or
0x45 or 0x34.

That's how it behaves if the test works. What results do you get if it fails ?
Post what happens when it fails.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 27, 2020 5:27 am     Reply with quote

What I mean about fail is that I don't get any serial communication. Just the LED blinks.

Working
With the 26K22 I am getting a byte every 2 seconds as expected and data+1 after sending a byte from the terminal.

Fails
With the 12F1840 and 16F1847 not getting a byte every 2 seconds and no data+1 after sending a byte from the terminal.

Best wishes
Joe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 27, 2020 1:04 pm     Reply with quote

I installed CCS vs. 5.062 and tested it with a 16F1847. I used your test
program from here:
http://www.ccsinfo.com/forum/viewtopic.php?t=58552&start=14
It worked.

Have you checked your pinouts ?
The 18F26K22 uses pins C6, C7 for Tx, Rx.
The 16F1847 uses B2, B1 for Tx, Rx.
The 12F1840 uses A0, A1 for Tx, Rx.
When you change PICs, the serial port pins change.
temtronic



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

View user's profile Send private message

PostPosted: Thu Feb 27, 2020 1:07 pm     Reply with quote

Any chance those PICs have assignable serial pins, using the APFCON register ?? IF so, what should be defaults may not be if the 'Wizard' is involved.
Ttelmah



Joined: 11 Mar 2010
Posts: 19253

View user's profile Send private message

PostPosted: Thu Feb 27, 2020 1:16 pm     Reply with quote

You are sure you are checking the right pins?.
The default is RX on RB1, TX on RB2.
You should also turn off the SPI peripheral since this can share the pins.
The code will differ massively, understand the PIC12/16 have different
instruction capabilities than the PIC18. The compiler generates working
code, so something is wrong in what is being done.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 27, 2020 5:10 pm     Reply with quote

Hi

I changed PIC's to new and everything working.
It seems that I damaged the PIC's during my testings Sad

Sorry for all this topic and the time spent to try to help me Embarassed
Apologizing for that Embarassed

If the moderator can delete all this topic, please delete.

Best wishes
Joe
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 Previous  1, 2
Page 2 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