It is currently 15 Oct 2018 20:05

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Soft_UART and 12F series
PostPosted: 31 Mar 2017 04:43 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Would like to know if the PIC12F series will work with Soft_UART.
I have tried using 12F683 without any success.
Any ideas, suggestions, tips or tricks welcomed.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
PostPosted: 31 Mar 2017 11:58 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi,

You can try code from attachment.
I have tested with PIC12F683 on EasyPIC v7 board.

Kind regards,
Lana


Attachments:
UART.zip [10.63 KiB]
Downloaded 53 times
Top
 Profile  
 
PostPosted: 01 Apr 2017 08:08 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Hi Lana,
Thanks for the reply.
I transcribed your C code example to MikroPascal, and it "almost" works.

The "write" works, but the problem is with the "receive".

eg:
The text I send does not return, and when I use the following code GPIO.2 does not turn on.

while TRUE do // Endless loop
begin
receive := Soft_UART_Read(error); // Read byte, then test error flag
if (error <> 0) then // If error was detected
GPIO.2 := 1 // signal it on PORTB
else
Soft_UART_Write(receive); // If error was not detected, return byte read
if receive = 'A' then GPIO.2 := 1;
if receive = 'B' then GPIO.2 := 0;
.......

I have managed to get the Soft_UART to work using a 16F628A, but I had to alter the code a lot from that as in the supplied example, plus I needed to set the interrupt and use the BREAK command, as described in the example as the Soft_UART is apparently a "blocking" routine and prevents the code from running, as I found out in the 16F628A test.

When I use the exact same technique as used with the 16F628A in the 12F683 (using gpio.1/0) the code does not function, except for the 'Z' to 'a' count-down routine, that only runs once as expected (write).

Is their something not correct about the 'receive' instruction?
Can you get the receive to work?

Many thanks,
Lew.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
PostPosted: 04 Apr 2017 14:58 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi Lew,

I'm sorry, I have missed headline.

You can try example in attachment, it is in mikroPascal,
it should receive character when it is sent from UART terminal too.

Kind regards,
Lana


Attachments:
UART.zip [10.63 KiB]
Downloaded 41 times
Top
 Profile  
 
PostPosted: 05 Apr 2017 00:34 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Hi Lana,

No, it does not work.

As I explained previously, the Transmit code works OK but NOT THE RECEIVE !

ie:

Send 'A' and 'B' from PC via serial port:-

If receive = 'A' then GPIO.2 := 1;
If receive = 'B' then GPIO.2 := 0;
This will not work.

Forget about the A to z that is generated in the uP and then sent to the PC - that will work as it is ONLY USING THE TRANSMIT code and not the receive.

If I use the exact same hardware setup and use Microchip MPLAB then everything works fine, even PIC12F629/675 and 683.

So maybe there is some memory problem with MikroPascal, or something not good in the function written by Mikro?

I hope you now understand my query, how else can I explain it to you.

Again: THE RECEIVE DOES NOT WORK !


Thanks,
Lew.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
PostPosted: 05 Apr 2017 08:56 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi Lew,

I have tested code before sending and it was working,
I also add part for receiving character from UART terminal.

It was tested on EasyPIC v7 board.

If you are using your own hardware, can you send your schematic?

If you are using one of our development boards,
can you send detailed image of it?

Kind regards,
Lana


Top
 Profile  
 
PostPosted: 06 Apr 2017 05:35 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Hi Lana,

As mentioned my hardware works fine using Microchip MPLAB, also same hardware when using 16F628A, as well as 12F629/675.

12F629/675 will not compile under Mikropascal due to memory restraints, understandably so.
16F628A compiles and runs fine with hardware and Mikropascal.

12F683 compiles and runs, except as mentioned will not receive character.

Nothing wrong with my hardware, have used this hardware configuration since 1990 (27 years).

Can you please send me a copy of the code you used ("I also add part for receiving character from UART terminal.") as I would really like to see it operate.

Many thanks,
Lew.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
PostPosted: 06 Apr 2017 15:01 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi Lew,

lewjoubert wrote:

12F683 compiles and runs, except as mentioned will not receive character.

I really couldn't reproduce the same behavior on EasyPIC v7 board.
You can try on different GPIO pins to initialize Soft_UART.

lewjoubert wrote:

Can you please send me a copy of the code you used ("I also add part for receiving character from UART terminal.") as I would really like to see it operate.



I have sent it here:

viewtopic.php?f=93&t=69847#p281577

But here is a part which was added:

while TRUE do                            // Endless loop
    begin
      byte_read := Soft_UART_Read(error);  // Read byte, then test error flag
      if (error <> 0) then                 // If error was detected
        GPIO.B1 := 1                       // Signal it on GP1
      else
        Soft_UART_Write(byte_read);        // If error was not detected, return byte read
    end;


Kind regards,
Lana


Top
 Profile  
 
PostPosted: 07 Apr 2017 00:37 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Hi Lana,

It does not work - have tried every possible way to accomplish this.

It work fines when coded and compiled with Microchip MPLAB.

With MikroPascal can only get Soft_UART_Write() to work.

Are you certain you can turn ON/OFF output GPIO.2 by sending characters 'A' and 'B' respectively?

Regards,

Lew.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
PostPosted: 07 Apr 2017 17:37 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi Lew,

Can you please send me the minimal project which represents the issue in a zip/rar archive?
I will test it on EasyPIC v7 board and let you know about the results.

Kind regards,
Lana


Top
 Profile  
 
PostPosted: 08 Apr 2017 00:54 
Offline

Joined: 12 Apr 2006 11:55
Posts: 68
Location: Gold Coast Australia
Hi Lana,

Will do. I am away for a few days and will send as soon as possible.

Very interested to find out where I am going wrong - thanks for your assistance.

Lew.

_________________
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to: