View previous topic :: View next topic |
Author |
Message |
pinkfloyd11
Joined: 02 Jul 2007 Posts: 247
|
Posted: Thu Jan 24, 2008 11:40 am Post subject: Strange behavior of PINX |
|
|
Dear Friends
I have written this code for read data from memory:
Dim Value_read as Byte
call set_address()
Config PORTC = INPUT
PortC = 255 'Set pull up on port C
Value_Read = PINC
print "Value = " ; Value_Read ; " PINC = " ; PINC
The strange is that Value_Read is different from PINC
Why?? |
|
Back to top |
|
|
kasko
Joined: 26 Jul 2004 Posts: 22
|
|
Back to top |
|
|
PAUWELYN
Joined: 16 Dec 2006 Posts: 37
|
Posted: Sat Jan 26, 2008 8:21 pm Post subject: |
|
|
hi
What a coincidence : today i had the same problem with ATmega16 : see code : Value = Pinc = 195 . All pins are high , except PC.2 . Value 195 = &B11000011 ; It's like the middle is dead . In fact i wish only evaluate the first 3 bits with a AND-mask .
I connected 2 ATmega16 togehter with reset and PC.2 . I don't know if that is permitted but i trayed with a new at16, but single, and still have the same problem.
Ernest
Code: | $regfile = "m16def.dat"
$crystal = 16000000
$baud = 9600
$hwstack = 32
$swstack = 8
$framesize = 16
$lib "lcd4busy.lib"
Const _lcdport = Porta
Const _lcdddr = Ddra
Const _lcdin = Pina
Const _lcd_e = 1
Const _lcd_rw = 2
Const _lcd_rs = 3
Config Lcd = 16 * 2
Config Portc = Input 'DDRC=&b00000000
Portc = &B11111111 'pull-up's on
Dim Value As Byte
Cls
Lcd "TEST"
Wait 1
Do
Value = Pinc 'And &B00000111
Cls
Lcd Value ; " " ; Pinc
Waitms 100
Loop
End |
|
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Sat Jan 26, 2008 9:03 pm Post subject: |
|
|
Hi Ernest,
Works here. The 8 pins of port C work.
The code below was tested with an ATmega16 and an Atmel STK500 board.
Verify your board and disable the JTAG.
Best regards,
Luciano
Used code:
Code: | $regfile = "m16def.dat"
$crystal = 16000000
$baud = 9600
$hwstack = 32
$swstack = 16
$framesize = 40
Config Portc = Input
Portc = &B11111111 'pull-up's on
Dim MyByte As Byte
Do
MyByte = Pinc
Print Bin(MyByte)
Waitms 1000
Loop
End |
Last edited by Luciano on Sat Jan 26, 2008 9:05 pm; edited 1 time in total |
|
Back to top |
|
|
PAUWELYN
Joined: 16 Dec 2006 Posts: 37
|
Posted: Sat Jan 26, 2008 9:04 pm Post subject: |
|
|
I found it : PORTC serves the JTAG interface==> disable !
I have to read first the datasheets before pannic |
|
Back to top |
|
|
|