Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Porting from m644p to m128... Or what I'm doing wrong?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP
View previous topic :: View next topic  
Author Message
PtG76

Bascom Member



Joined: 18 Apr 2013
Posts: 11
Location: Uzhhorod

ukraine.gif
PostPosted: Tue Apr 30, 2013 1:00 pm    Post subject: Porting from m644p to m128... Or what I'm doing wrong? Reply with quote

Hello everybody!

I'm tying to port program from ATmega644p to ATmega128.
RTC PCF8583 is working fine. LCD handling also. Cool
But I cannot work nether with RFID nor with Ethernet. Brick wall
I attached my proggie only with eth. Or it is not possible
to connect ethernet to this controller?..

Please help

Sincerely, Peter
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Apr 30, 2013 1:51 pm    Post subject: Reply with quote

Hello Peter

These are too small for this program
$hwstack = 32
$swstack = 10
$framesize = 40

The program makes use of locals which come from there if you look at my webserver blog you will see how large I had to make them this is one reason why I used the mega1284p with its 16K of ram but you have plenty in the m128 so make them much larger.

Regards Paul
Back to top
View user's profile
PtG76

Bascom Member



Joined: 18 Apr 2013
Posts: 11
Location: Uzhhorod

ukraine.gif
PostPosted: Tue Apr 30, 2013 8:06 pm    Post subject: Reply with quote

Paulvk wrote:

These are too small for this program
$hwstack = 32
$swstack = 10
$framesize = 40

Thank you, Paul. I've rise the values of these attributes... And it works Smile
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Wed May 01, 2013 12:05 am    Post subject: Reply with quote

It is good that you have it working. Have a look at my program in particular the many comments I have made there is a great deal of information about the ENC28J60 , the way it wants to be connected and controlled you will see that it is best to run the AVR from its clock ouput I run my one at 12.5mHz as the ENC28J60 SPI buss is unstable at less than 10mHz so you would need an AVR at 20mHz with the SPI buss at high speed to get the AVR SPI to 10mHz, I show the set up of the ENC28J60 to do this , also I show how to run the SPI buss at high speed (half the cpu clock) , the biasing resistor on the ENC28J60 needs to be the correct one for its revision and the only way to determ this is to read the revision number from the ENC28J60 as its not printed on the outside then you need to read the data sheet to find which one to use, the AVR can be run at 5V as the ENC28J60 inputs are rated for this even though it runs at 3V. Those are some of the more important things but there is a lot more.

Regards Paul
Back to top
View user's profile
PtG76

Bascom Member



Joined: 18 Apr 2013
Posts: 11
Location: Uzhhorod

ukraine.gif
PostPosted: Wed May 01, 2013 11:56 am    Post subject: Reply with quote

Dear, Paul

Thanks a lot for help:) Just one question: Is it possible to work with EM4095 RFID Reader on
ATmega128 either? I worked with EM4095 RFID Reader on ATmega644P (on evolution board)
using interrupts, configured "on change". Like a code below
Code:

$regfile = "m644pdef.dat"
$baud = 9600
$crystal = 16000000

Config Lcdpin = Pin , Rs = Portc.2 , E = Portc.3 , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2
Cls
Cursor Off Noblink

Dim Tags(5) As Byte , J As Byte

Config Hitag = 64 , Type = Em4095 , Demod = Pind.2 , Int = @int0
Rfid_mod Alias Portd.4
Rfid_mod_pin Alias Pind.4
Rfid_shd Alias Portd.3
Rfid_shd_pin Alias Pind.3

Config Rfid_mod_pin = Output
Config Rfid_shd_pin = Output

Reset Rfid_mod
Reset Rfid_shd
Waitms 100
Set Rfid_shd
Waitms 100
Reset Rfid_shd

On Int0 Checkints Nosave
Config Int0 = Change
Enable Interrupts

Do
  If Readhitag(tags(1)) = 1 Then
    Locate 1 , 1
    For J = 1 To 5 Step 1
      Lcd " " ; Hex(tags(j))
    Next J
  End If
Loop
End

Checkints:
Call _checkhitag
Return
 


I tried to combine something for M128, but with no result. I Googled whole night long and I found this for m128:
Code:

$regfile = "m128def.dat"
$crystal = 16000000

Dim A As Byte , B1(10) As Byte , B2(10) As String * 1 , C As Byte , T As Bit
Dim Rfid As String * 10
Config Graphlcd = 240 * 128 , Dataport = Portb , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6

Cursor Off
Cls

C = 1
Locate 1 , 1
Lcd " 125Khz RFID-Reader"
Locate 2 , 1
Lcd " Unique, HT4102" ' <-- EN4102 is a transponder

Do
  A = Inkey()
  If A > 32 Then
    B1(c) = A
    B2(c) = Chr(b1(c))
    If C = 10 Then
      Rfid = B2(1) + B2(2) + B2(3) + B2(4) + B2(5) + B2(6) + B2(7) + B2(8) + B2(9) + B2(10)
      Locate 4 , 1
      Lcd Rfid
      Locate 6 , 1
      Lcd B1(1) ; B1(2) ; B1(3) ; B1(4) ; B1(5) ; B1(6) ; B1(7) ; B1(8) ; B1(9) ; B1(10)
      C = 0
    End If
    Incr C
  End If
Loop

End
 

So, the question (maybe a newbie): Can I work with EM4095 RFID via interrupts or UART on
ATmega128?

Many thanks, Peter
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> EASY TCP/IP All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum