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

PIC18f4520 and e8051 uart mode - help needed

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
silelis



Joined: 12 Jun 2007
Posts: 57

View user's profile Send private message

PIC18f4520 and e8051 uart mode - help needed
PostPosted: Mon Oct 02, 2017 10:26 am     Reply with quote

Hello,

I have to communicate with my PIC (20MHz) with 8051 "like" mcu. It is UART transmission. Exactly it is au7860 mcu and it's communication protocol is here.

Generally it is:
Quote:

In slave mode, UART is used for communication in 8bit asynchronous transfer mode,
defaulting GPIOA0 as TX, GPIOA1 as RX and 57,600bps as baud rate. Format of each byte is
as follows:

|START bit | 0 bit, 1 bit .... 7 bit| STOP bit|

Packet Format:
0x55 | 0xAA | len | Cmd_H | CmD_L| data (x len) | CS

In example the simplest command is:
0x55
0xAA
0x0
0x0104 - Cmd_H CmD_L
0x0
0xFB


The C51 "like" storage mode is BIG-END mode, upper bytes are stored in the low address of the memory, and lower bytes are stored in the upper address of the memory.
so 0x12 is sent as: 0 -> 1 -> 0 -> 0 -> 1 -> 0 -> 0 -> 0.

And here is my questions
1) My PIC is LOW-END as I know it correctly?
2) Is there in CCS bit reverse routine?
3) Do PIC perform 57600 bps speed?
4) the 0x0104 should be reversed as one or I should divide it on 0x01 and 0x04 and reverse it separately?
temtronic



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

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 5:29 am     Reply with quote

Overall this is just 'regular' serial communications, so no need to reverse the bits or those cmd bytes. The 'device' needs the data sent in the order you show.

NOW the big 'issue' is the hardware. That PDF is just the commands and doesn't explain the interface connections.
Typically , most 'devices' today are 3 volts so it's best to select a 3 volt PIC. Any( most ?) with L in them ( ie: 16LF84 ) are designed to run on 3 volts. Some PICs, like the 18F46K22 are designed to run on 5 or 3 volts. You don't say which PIC you're using...that's an important detail!

UART could mean 'TTL' signals. The datasheet will explain what is required. Hopefully it's as simple as connecting the PIC's XMT pin to the MP3's RCV pin, and the PIC's RCV pin to the MP3's XMT pin.

To begin, cut code to send a SIMPLE command to the device and display the result either to a local LCD or PC terminal program. Confirm that works, then test other commands. One step at a time...wins !

Jay
silelis



Joined: 12 Jun 2007
Posts: 57

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 5:42 am     Reply with quote

The PIC is 18f4520 but the mp3 hardware is secured with resistors provided voltage drop on au7860 UART port. MP3 hardware developer assure that it is enough but in my final hardware I will use BSS138 logic level converter.
temtronic



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

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 6:37 am     Reply with quote

I downloaded the datasheet for the 4520 and it'd be easier for you to just order/use the 18LF4520 PIC. That way NO additional parts needed between PIC and MP3 device !
Also then you only need a 3 volt power supply.

Jay
silelis



Joined: 12 Jun 2007
Posts: 57

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 7:44 am     Reply with quote

Where can I find this pic18LF4520 datasheet I can see only pic18F4520 at the net??
newguy



Joined: 24 Jun 2004
Posts: 1480
Location: Edmonton, Alberta

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 7:46 am     Reply with quote

It's the same data sheet. Only difference lies in acceptable power supply voltage range, and there is usually also a difference in maximum clock speed vs power supply voltage. Those differences are spelled out in the electrical specifications chapter of the data sheet.
silelis



Joined: 12 Jun 2007
Posts: 57

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 7:51 am     Reply with quote

Ohhh I see.

Any in this LF version is possible to supply it with 5V0 and to set it (in come register) that outputs are 3V3??

Asking because some fo my devices are supplied with 5V0. Or it is like this that which power supply mcu this voltage is on outputs??
silelis



Joined: 12 Jun 2007
Posts: 57

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 7:59 am     Reply with quote

And how is it with cpu speed?

Do I understand it correctly that external quartz is the same (in my example 20 MHz) but only cpu speed changes?
newguy



Joined: 24 Jun 2004
Posts: 1480
Location: Edmonton, Alberta

View user's profile Send private message

PostPosted: Wed Oct 04, 2017 8:24 am     Reply with quote

With any PIC I'm aware of, it's not possible to have them output a normal digital output voltage that is different from their power supply. So 5V supply to your PIC means that a logic high will be 5V. There are, however, PICs that are meant to run at 3.3V but will tolerate 5V inputs. dsPICs in particular have this capability on some of their ports/pins, but not all.

Regarding your speed/crystal question, look at pages 322 and 323 of the data sheet. For the "F" parts, they'll run at a speed of up to 25MHz at power supply voltages of 4.2V and above. As you'll then see on page 323, for "LF" parts, their maximum speed depends on power supply voltage. The equation for the line is given below the graph.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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