Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

some basic PIC microcontroller question..need your help

Status
Not open for further replies.

wcgan

Member level 2
Joined
Nov 1, 2006
Messages
43
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,604
Hi all,

I am fresh to PIC controller, i hv some basic microcontroller question need you help..

Question 1:Memory Size:
For 8051, datasheet written
- 128 x 8-bit Internal RAM

is that means 1 memory location can store 8-bits data. total hv 128 memory location, so the total memory RAM size is
128 x 8 bits = 1024 bits
128 x 1 byte = 128bytes

is that the same calcucaltion theory can apply to PIC controller?
from PIC16F876 datasheet,

Up to 8K x 14 words of FLASH Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM)
Up to 256 x 8 bytes of EEPROM Data Memory


is that means 1 memory location can store 8-bytes data, total hv 368 memory location, so the total memory size is

#cal1
368 x 8 x 8 bits = 23552 bits
368 x 8 bytes = 2944 bytes

OR

#cal2
368 x 8 bits = 2944 bits
368 x 1 byte = 368 bytes

which calculation is correct? if cal2 is correct, y the unit display on datasheet is 'bytes' NOT 'bits'?
Up to 368 x 8 bits of Data Memory (RAM)
is that the standard display way for the microcontroller?

Up to 8K x 14 words of FLASH Program Memory
1 words = 4 bytes
8k x 14 words = 8k (memory location) x (14 x 4) = 448000 bytes?

Question 2:14-bits op-code vs. 8-bits op-code:
what means of 14-bits op-code? what r the different between 8 bits op-code?
is that means they can do more task on one command?

example:
A = 0x05 + 0x09;

in 8051,(8-bits op-code)
ADD A,#05H
ADD A,#09H

in PIC,(16-bits op-code)
ADD A,#05H,#09H

16-bits op-code can done the job on one 'ADD' command?

Thanks for your help.
 

#1, ram is counted in bytes not bits
#2, PIC has paging and banking that's why it has extra bits in its op code to switch between banks or pages
 

penoy_balut said:
#1, ram is counted in bytes not bits
#2, PIC has paging and banking that's why it has extra bits in its op code to switch between banks or pages

sorry, i am not understand yet.
u mentions ram is counted in bytes. is that means PIC16F876A total RAM size r 2944 bytes?
368 x 8 bytes = 2944 bytes
 

368 x 8 means 368 registers of 8 bit data, that is for 8-bit microcontroller
 

    wcgan

    Points: 2
    Helpful Answer Positive Rating
penoy_balut said:
368 x 8 means 368 registers of 8 bit data, that is for 8-bit microcontroller


because the PIC16F876 datasheed showing that
368 x 8 bytes,after the 8 following with 'bytes' not 'bits', so i confuse on the number of 8 is represent of 'bit' or 'byte'.
 

if that's a 16-bit microcontroller it could have been written as 368 x 16
 

    wcgan

    Points: 2
    Helpful Answer Positive Rating
thanks. i understand the memory size already.
but i still cant understand wat r the different between
14-bits op-code vs. 8-bits op-code...

hope you can give me a sample on it.. thanks a lot.
 

programming PIC as a beginner does not require the knowledge about op code, familiarize yourself in its instruction sets, register addressing, banking and paging, after that you'll know how op code works
 

[ SPI Clock Problem ]

Hi ,

I would like to generate 500k SPI clock with external crystal 4Mhz.

from datasheet, SPI clock have 4 modes(SSPCON)
0000 = SPI Master mode, clock = FOSC/4
0001 = SPI Master mode, clock = FOSC/16
0010 = SPI Master mode, clock = FOSC/64
0011 = SPI Master mode, clock = TMR2 output/2

SCK = 1Mhz (FOSC/4, with crystal 4Mhz)
SCK = 250khz (FOSC/16, with crystal 4Mhz)
the first 3 modes cant fullfill my requirment to generate 500khz.

Only mode 4 can customize the frequency, TMR2 output / 2.
my settings was shown below:
//SPI Settings
SSPIE = 0;
SSPEN = 0 ;

SSPSTAT= 0b11000000 ;
SSPCON = 0b00010011 ; // using mode 4

CKP = 1 ;
CKE = 0 ;
SMP = 1 ;
SSPEN = 1 ;

// Timer2 Settings
TOUTPS3 = 0; // Post Scaler = 1
TOUTPS2 = 0; //
TOUTPS1 = 0; //
TOUTPS0 = 0; //

T2CKPS1 = 0; // Prescaler = 1
T2CKPS0 = 0; //

TMR2 = 0;
PR2 = 1;
TMR2IE = 0;
PEIE = 0;
GIE = 0;
TMR2ON = 1;

Calculation:
Timer2 Clock Prescale Select bits = 1:1
FOSC = 4Mhz
FOSC/4 = 1Mhz(1us)
TMR2=0, PR2=1
TMR2 Output = 1Mhz (1us)

SPI
Synchronous Serial Port Mode Select bits = TMR2 output/2
= 1Mhz / 2
= 500khz(2us)

But i probe SCK pin from osillacscope, the frequency is 250khz (4us), anything goes wrong in my settings or wrong calculation?

Thanks.
 

thanks..
i found out the reason.

TMR2 output = (4 / FOSC) x N x (PR2 + 1)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top