Hi All
I have been working on a project for some time but due to time constraints have not had time to pursue for some months
My project involves sending data too and from a Master / Slave using two PICS
But for the time being I found a nice write up on the web to send a piece of data to an EPROM, read it back and then light 8 LEDS on the PIC
The code uses a PIC16F877 (which I have not currently got)
I do have several 16F887's with internal clock
So I decided to modify the code to fit
When I compiled it, it did not like the #Define statements
Much research on the web did not enlighten me (It looks like C language or a macro)
So I cheated and used CBLOCK to define the labels then moved the values into the labels using
movlw 0x34
movlf DATA
where before they used #Define DATA
#define LC01DATA H’34’ ; Sample data to write to EEPROM
I cut out the baud rate part of the program because the compiler did not like it, and it all passes
So now I need to put the clock speed back in and simulate the program
Did the same trick with cblock but the compiler complained
I think that I was trying to put 4,000,000 into memory of 8 BITS
This is 3D0900 in Hex
I guess with CBLOCK I have sequentially used memory in blocks of 8 BITS
So the maximum value is FF per memory address
The D'100' should work as Binary 64
The formula seems to be FOSC divided by 4* (SSPADD +1)
Basically resulting in 100 MHZ Clock Rate for a 4MHZ Oscillator
Is there a simpler way to program this statement in (using assembler)
Can someone explain the #DEFINE and why MPLABSIM will not compile it
I am confused about this statement
BANKSEL SSPADD
movlw (FOSC / (4 * BAUD)) - 1 ; Calculates SSPADD
movwf SSPADD ; for desired Baud rate
; and sets up SSPADD
Can they not say
In effect 4,000,000 / (400))
= 100,000
minus 1
So SSPADD = 99999
11000011010011111 in binary
Which is surely too large for the SSPADD register ??
Confused ?
I know I am
Any help appreciated
For info I found the tutorial program here
It is a copy of the original Microchip document
http://galaxy.eti.pg.gda.pl/katedry/ksg/dydaktyka/dla_studentow/i2c.pdf
I have been working on a project for some time but due to time constraints have not had time to pursue for some months
My project involves sending data too and from a Master / Slave using two PICS
But for the time being I found a nice write up on the web to send a piece of data to an EPROM, read it back and then light 8 LEDS on the PIC
The code uses a PIC16F877 (which I have not currently got)
I do have several 16F887's with internal clock
So I decided to modify the code to fit
When I compiled it, it did not like the #Define statements
Much research on the web did not enlighten me (It looks like C language or a macro)
So I cheated and used CBLOCK to define the labels then moved the values into the labels using
movlw 0x34
movlf DATA
where before they used #Define DATA
#define LC01DATA H’34’ ; Sample data to write to EEPROM
I cut out the baud rate part of the program because the compiler did not like it, and it all passes
So now I need to put the clock speed back in and simulate the program
Did the same trick with cblock but the compiler complained
I think that I was trying to put 4,000,000 into memory of 8 BITS
This is 3D0900 in Hex
I guess with CBLOCK I have sequentially used memory in blocks of 8 BITS
So the maximum value is FF per memory address
The D'100' should work as Binary 64
The formula seems to be FOSC divided by 4* (SSPADD +1)
Basically resulting in 100 MHZ Clock Rate for a 4MHZ Oscillator
Is there a simpler way to program this statement in (using assembler)
Can someone explain the #DEFINE and why MPLABSIM will not compile it
I am confused about this statement
BANKSEL SSPADD
movlw (FOSC / (4 * BAUD)) - 1 ; Calculates SSPADD
movwf SSPADD ; for desired Baud rate
; and sets up SSPADD
Can they not say
In effect 4,000,000 / (400))
= 100,000
minus 1
So SSPADD = 99999
11000011010011111 in binary
Which is surely too large for the SSPADD register ??
Confused ?
I know I am
Any help appreciated
For info I found the tutorial program here
It is a copy of the original Microchip document
http://galaxy.eti.pg.gda.pl/katedry/ksg/dydaktyka/dla_studentow/i2c.pdf