Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 20, 2024, 12:23:59 00:23


Login with username, password and session length


Pages: [1]
Print
Author Topic: Proton 18F4550 HBusout problem  (Read 6721 times)
0 Members and 1 Guest are viewing this topic.
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« on: March 11, 2010, 02:14:10 14:14 »

Hi,

I have a problem with SSMP in 18F4550. I am trying to interface a pic 18F4550 (master mode) with an eeprom 24LC256 using Proton. But this doesnīt work:
    
    HBusOut $A0, direc, [%10101010]
        (direc is a Word variable)
    
I configure SDA and SCL pins as input:

    TRISB = %00000011

I configure SSMP registers as shown:
    
    SSPCON1 = %00101000                  
    SSPCON2 = %00000000
    SSPSTAT = %10000000


Of course, I use the pull-up resistors.

Any idea?
Thank you!!

« Last Edit: March 11, 2010, 02:22:31 14:22 by Nele » Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 747

Thank You
-Given: 169
-Receive: 1289



« Reply #1 on: March 11, 2010, 09:44:23 21:44 »

HbusOut works 100% for me. there is no need to define SSPCON1 SSPCON2 and SSPSTAT registers. When using HbusOut the compiler add the initializing code in the beginning.
Logged
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #2 on: March 14, 2010, 08:24:00 20:24 »

Using a 16F877, the HBUSOUT command works fine.

But, when I try it in a 18F4550, it doesnīt work.

Device = 18F4550
Xtal = 4

LCD_Interface 4
LCD_Lines 2
LCD_DTPin PORTD.4
LCD_RSPin PORTD.0
LCD_ENPin PORTD.1

Dim direccion As Word
Dim dato As Byte

Symbol ControlW = %10100000
Symbol ControlR = %10100001
inicio:

TRISD=0
PORTD=0

dato = %10101010
direccion=0
HBusOut ControlW, direccion, [dato]
DelayMS 10
dato = HBusIn ControlR, direccion
Print At 1,1, Hex dato
Stop
End
« Last Edit: March 14, 2010, 08:37:10 20:37 by Nele » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #3 on: March 14, 2010, 09:01:26 21:01 »

looks like you have some code missing, and what port and pins are you using>
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
gem1144aaa
Junior Member
**
Offline Offline

Posts: 88

Thank You
-Given: 134
-Receive: 27


« Reply #4 on: March 14, 2010, 09:07:40 21:07 »

i have also the same problem but with the shin "shift in" and shout "shift out"

they work great for 16f877 but when moving to 18f452 if fills my text lcd with a lot of garbage everywhere

Logged
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #5 on: March 14, 2010, 09:17:30 21:17 »

Same code, using a 16F877 works fine.

The only diference is that SSMP module on 18F4550 is in PORTB.
Logged
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #6 on: March 14, 2010, 10:05:52 22:05 »

I have added this to the code:

Declare Hbus_Bitrate 100
Declare SDA_Pin PORTB.0
Declare SCL_Pin PORTB.1
Declare Slow_Bus On


And problem persists.

Is it a bug of the compiler?
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #7 on: March 14, 2010, 10:26:03 22:26 »

Proton should use these as default are you using same pins?
Hardware I2C Pin Definitions for 16F877
[HI2CSTART]
_I2C_SCL_PORT = TRISC
_I2C_SCL_PIN = 3
_I2C_SDA_PORT = TRISC
_I2C_SDA_PIN = 4
[HI2CEND]

Hardware I2C Pin Definitions for 18F4550
[HI2CSTART]
_I2C_SCL_PORT = TRISB
_I2C_SCL_PIN = 1
_I2C_SDA_PORT = TRISB
_I2C_SDA_PIN = 0
[HI2CEND]
have you tried to build it in Proteus?
« Last Edit: March 14, 2010, 10:28:59 22:28 by pickit2 » Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
gem1144aaa
Junior Member
**
Offline Offline

Posts: 88

Thank You
-Given: 134
-Receive: 27


« Reply #8 on: March 14, 2010, 10:30:16 22:30 »

what should be noticed here with all libraries that do the clocked synchronous data transmission has a problem with pic18 family so mostly i think is something missing as some sort of initialization or kinda

couldn't be a bug with all these libraries i think or if it were a bugs then i can't comment it.
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #9 on: March 14, 2010, 10:38:15 22:38 »

At this time I'm looking for a problem thats buging me so while I'm looking, I see some posts that cross my problem and your.
new question you do have pull up resistors fitted?


setup for 18F452

SSPSTAT = %00000000
SSPCON1 = %00101000     'I2C Enabled, I2C Master mode, clock = FOSC / (4 * (SSPADD+1))
SSPCON2 = %00000000
« Last Edit: March 14, 2010, 10:55:27 22:55 by pickit2 » Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
gem1144aaa
Junior Member
**
Offline Offline

Posts: 88

Thank You
-Given: 134
-Receive: 27


« Reply #10 on: March 14, 2010, 10:56:29 22:56 »

yes PicKit

its all connected correct and runs great on pic 16f877 when only change to pic18 then it goes crazy
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4647

Thank You
-Given: 826
-Receive: 4207


There is no evidence that I muted SoNsIvRi


« Reply #11 on: March 14, 2010, 11:06:56 23:06 »

found this and it seems to work in proteus.

Code:
 Device = 18F4550                                               
 Clear
 Xtal = 20          
        
' ** Declare some USER Variables **        
        Dim ADDRS    As    Word
        Dim E_BYTE    As    Byte                                ' Byte read/written to eeprom
        
' ** MAIN PROGRAM STARTS HERE **
                  
        Cls                                                    ' Clear the LCD
' Write to the first 11 address's of the Eeprom
        For ADDRS = 0 To 10                                    ' Create a loop of 11
            E_BYTE = ADDRS                                ' Place the byte to be transmitted into E_Byteout        
            HBusOut %10100000 , ADDRS , [E_BYTE]            ' Write the byte to the Eeprom
            Print At 1,1,"Data Written ",Dec E_BYTE,"  "
            DelayMS 200
        Next                                                ' Close the Loop
        DelayMS 500

' Read the first 11 address's within the Eeprom,    
' and display them on the LCD
AGAIN:  Cls                                                    ' Clear the LCD
        For ADDRS = 0 To 10                                    ' Create a loop of 11        
            HBusIn %10100000 , ADDRS , [E_BYTE]              ' Receive the byte from the eeprom
            Print At 1,1,"Address   ",Dec ADDRS,"   ",At 2,1,"Data Read ",Dec E_BYTE,"  "      ' Print the value read in from the eeprom
            DelayMS 400                                        ' Delayms between displays, for drama
        Next                                                ' Close the loop
        GoTo AGAIN


Posted on: March 14, 2010, 11:05:39 23:05 - Automerged

removed LCD so you need to put yours in there.
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #12 on: March 14, 2010, 11:11:05 23:11 »

I have simulated that code in proton and doesnīt work.

Also,I used it in my trainer, and the result is same, it doesīnīt work.

The result is:

Address 0
Data Read 255

Address 1
Data Read 255
...
Logged
gem1144aaa
Junior Member
**
Offline Offline

Posts: 88

Thank You
-Given: 134
-Receive: 27


« Reply #13 on: March 14, 2010, 11:13:51 23:13 »

i appreciate you immediate response PicKit

i did the initialization you wrote but still the problem no change

what i think it could require an initialization of some system variables mentioned in the proton help topics

The following reserved words should not be used as variable names, as the compiler will create these names when required: -
 
PP0, PP0H, PP1, PP1H, PP2, PP2H, PP3, PP3H, PP4, PP4H, PP5, PP5H, PP6, PP6H, PP7, PP7H, PP8, PP9H,GEN, GENH, GEN2, GEN2H, GEN3, GEN3H, GEN4, GEN4H, GPR, BPF, BPFH.


as in one post on the proton forum Tim suggested to put

BPF = 0

  
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 747

Thank You
-Given: 169
-Receive: 1289



« Reply #14 on: March 15, 2010, 09:45:46 09:45 »

Well i think i have the solution. RB0 and RB1 are two analog input by default, you need configure them as digital then try your code.

You can use "ALL_DIGITAL = TRUE"

or in configurations put "PBADEN = OFF"
Logged
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #15 on: March 15, 2010, 03:02:59 15:02 »

Hi Ahmad_k,

I have test "All Digital = true" and PBADEN config but they didnīt solve the problem.
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 747

Thank You
-Given: 169
-Receive: 1289



« Reply #16 on: March 15, 2010, 08:07:25 20:07 »

Put your complete code here so we can help you better.
Logged
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #17 on: March 15, 2010, 08:40:38 20:40 »

This is the code thay I use for the test. Same code works fine in a 16F877 pic.

Code:
' Using the Master Synchronous Serial Port (MSSP). Configured as an I2C master.

Device = 18F4550
Xtal = 4

Config_Start
WDT = OFF
MCLRE = On ' RE3 input pin disabled; MCLR enabled
PBADEN = OFF ' PORTB<4:0> pins are configured as digital I/O on Reset
LVP = OFF ' Single-Supply ICSP disabled
Debug = OFF ' Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Config_End

LCD_Interface 4
LCD_Lines 2
LCD_DTPin PORTD.4
LCD_RSPin PORTD.0
LCD_ENPin PORTD.1

All_Digital = TRUE

Slow_Bus On

' ** Declare some USER Variables **        
        Dim ADDRS As Word
        Dim E_BYTE As Byte
        
' ** MAIN PROGRAM STARTS HERE **
        DelayMS 500        
        Cls
      
        
'Write to the first 11 address's of the Eeprom
        For ADDRS = 0 To 10
            E_BYTE = ADDRS
            HBusOut %10100000 , ADDRS , [E_BYTE]
            Print At 1,1,"Data Written ",Dec E_BYTE,"  "
            DelayMS 200
        Next
        DelayMS 500

' Read the first 11 address's within the Eeprom,
' and display them on the LCD
AGAIN:  Cls
        For ADDRS = 0 To 10
            HBusIn %10100000 , ADDRS , [E_BYTE]
            Print At 1,1,"Address   ",Dec ADDRS,"   ",At 2,1,"Data Read ",Dec E_BYTE,"  "
            DelayMS 400
        Next
        GoTo AGAIN
« Last Edit: March 15, 2010, 09:47:51 21:47 by Nele » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright Đ 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC