Iv been having a problem for 3 days now and cant seem to resolve it, I`v tried the most Basic of all programs here:
dir portc in
dir portb out
start:
portb=portc
goto start:
in theory this should output on port b any input on port c, Nada!
Iv tried it with 2 different Atmel MCUs and also on a PIC chip, stull nothing.
I can set the ports to any numeric value and it works, I just cant get that value from another port.
However Analogue (readAD) command does work!?
I`v even tried a single Bit of a port and the same thing happens.
it also seems to assemble just fine too, here:
;Start of the main program
ldi SysValueCopy,0
out DDRC,SysValueCopy
ldi SysValueCopy,255
out DDRB,SysValueCopy
START:
in SysValueCopy,PORTC
out PORTB,SysValueCopy
rjmp START
any idea why it`s suddenly started doing this?
it Used to work just fine before, but Now nothing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yup, Iv tried every single possible combination using all ports as either in or out, and over 3 different ICs on 2 different boards in case it was a hardware fault or blown port.
even tried adding wait statements betwen each action in case it was too fast and making RF noise.
Iv reinstalled my Original version of GCB too and tried that too, and on 2 different laptops.
everything was fine until I updated my 2010 version of GCB (I needed one of the new libraries) and all seemed to be fine except for this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
still nothing.
in fact it was something Similar to the above that lead me discover the problem, I was using Delay = portc to set the step rate for a stepper motor.
if its of any help, the RS232 RX and TX works justs fine, so theres nothing actually Wrong with the chips.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok, I tried all the DDR permutations and still the same effect, I even tried using a different uploader for the Hex file that GCB generates, and nothing?
I have had Partial success with this:
;Chip Settings
chip mega1284p,16
dir portc out
dir porta in
start:
If porta.0=1 then
portc=0
End if
If porta.0=0 then
portc=170
End If
goto start:
NB, I use 170 as the output number as its pretty distinctive and unlikely to be confused with anything else, thats all.
the above Does actually work, but still no way to read an entire ports Value?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Iv been experimenting Further and still cannot read the value of a whole port!?
all Im getting is 0 as a value when a read is tried, I used this code to test with:
;Chip Settings
chip mega1284p,16
;Defines (Constants)
define LCD_IO 8
define LCD_DATA_PORT portc
define LCD_RS PORTD.5
define LCD_RW PORTD.4
define LCD_Enable PORTD.3
dir portb in
dir porta in
cls
main:
cls
lcdint (portb)
porta= value
locate 1,0
print value
wait 200 ms
goto main:
in effect this just reads the value of ports A and B and displays them on the LCD, both read "0" no matter what input I try (hard GND or +5V).
so the GCB software is broken somewhere along the line.
Im using version 9, with all the latest updates unpacked into the correct folders.
does GCB call on any Other program outside of itself to upload or parse any data at all? maybe thats whats corrupted?
I Seriously need some Help with this as I have Design that needs to be finished at the end of the month and Iv wasted a week on this nonsense already :(
is anyone Else having a similar problem at all?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
error: GCASM: Symbol MEMADR has not been defined
same with MEMADR_H, MEMDATA and also PEEK.
the 1284P is my own chipdata, but I`m having the same problem with PIC chips too so I can pretty much rule that out.
Anobium, your program didnt work either (even after i added the #s for the defines).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had no problem compiling with Any chipset (PIC or Atmega), only the one that had the "Peek" commands in them,it Should work (and indeed used to work) using any of the code I posted in this thread.
meanwhile Iv found a pair of laptops that have never had GCB on them before, so Im going to try a 100% fresh instal on one and see how that goes.
Iv finally found a workaround after much messing about with code (which I didnt want to do hence I choose to use Basic).
DDRB = 0XFF
DDRD = 0X00
START:
Test = PIND
PORTB = Test
goto START:
This seems to work perfectly well, but Iv still got no idea why the same in pure Basic wont work though?
I`v also managed to get a 16F57 chip to work from pure basic, but Only after I read the chip from the PK2 software will the chip actually start to work as programmed.
Something somewhere is broken.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yup, all is perfect h/ware wise, Iv tried many different boards and ICs too.
the Problem that I can see so far as Im trying to lock it down, is the PORT command.
the DIR PORT x In/Out is fine (so no need for the DDRx)
and if I replace PORTx with PINx all works as it should when trying to Read a port.
if youre Outputting to a port, then fine, you can use PORTx, but its no good anymore to Read a whole port.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I really sorry but I cannot follow/fully understand the post.
My summary.
dir portx in|out works as expected. When you read and write the assigned port respectively.
dir pinx in|out only works when reading a pin. But, you have issues when reading pins? or do you mean reading a port?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sorry, my bad.
yes you can set the port Dir as normal.
and you can Output to a port as normal too.
but if you want to Read an entire port you can`t use the Port command, ie;
Var = PORTD will not work
instead I have to use;
var = PIND
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I
v been having a problem for 3 days now and can
t seem to resolve it, I`v tried the most Basic of all programs here:dir portc in
dir portb out
start:
portb=portc
goto start:
in theory this should output on port b any input on port c, Nada!
I
v tried it with 2 different Atmel MCUs and also on a PIC chip, stull nothing. I can set the ports to any numeric value and it works, I just can
t get that value from another port.However Analogue (readAD) command does work!?
I`v even tried a single Bit of a port and the same thing happens.
it also seems to assemble just fine too, here:
;Start of the main program
ldi SysValueCopy,0
out DDRC,SysValueCopy
ldi SysValueCopy,255
out DDRB,SysValueCopy
START:
in SysValueCopy,PORTC
out PORTB,SysValueCopy
rjmp START
any idea why it`s suddenly started doing this?
it Used to work just fine before, but Now nothing.
Have you tried setting portC to be an input?
yup, I
v tried every single possible combination using all ports as either in or out, and over 3 different ICs on 2 different boards in case it was a hardware fault or blown port. even tried adding wait statements betwen each action in case it was too fast and making RF noise. I
v reinstalled my Original version of GCB too and tried that too, and on 2 different laptops.everything was fine until I updated my 2010 version of GCB (I needed one of the new libraries) and all seemed to be fine except for this.
As a work around try this code:
dir portB out
dir portC in
wait 5 us ' ensure AVR has sufficient time to change port directions
my_variable =portC
portB =my_variable
still nothing.
in fact it was something Similar to the above that lead me discover the problem, I was using Delay = portc to set the step rate for a stepper motor.
if it
s of any help, the RS232 RX and TX works justs fine, so there
s nothing actually Wrong with the chips.Is this a LAT read\rite issue?
try... set latc = portc
currently I
m using an Atmega 1284p in there, so it
s probably stuff like DDR and the likes?but yes, it`s certainly a Read issue.
ok, I tried all the DDR permutations and still the same effect, I even tried using a different uploader for the Hex file that GCB generates, and nothing?
I have had Partial success with this:
;Chip Settings
chip mega1284p,16
dir portc out
dir porta in
start:
If porta.0=1 then
portc=0
End if
If porta.0=0 then
portc=170
End If
goto start:
NB, I use 170 as the output number as it
s pretty distinctive and unlikely to be confused with anything else, that
s all.the above Does actually work, but still no way to read an entire ports Value?
I
v been experimenting Further and still cannot read the value of a whole port!? all I
m getting is 0 as a value when a read is tried, I used this code to test with:;Chip Settings
chip mega1284p,16
;Defines (Constants)
define LCD_IO 8
define LCD_DATA_PORT portc
define LCD_RS PORTD.5
define LCD_RW PORTD.4
define LCD_Enable PORTD.3
dir portb in
dir porta in
cls
main:
cls
lcdint (portb)
porta= value
locate 1,0
print value
wait 200 ms
goto main:
in effect this just reads the value of ports A and B and displays them on the LCD, both read "0" no matter what input I try (hard GND or +5V).
so the GCB software is broken somewhere along the line.
I
m using version 9, with all the latest updates unpacked into the correct folders. does GCB call on any Other program outside of itself to upload or parse any data at all? maybe that
s whats corrupted? I Seriously need some Help with this as I have Design that needs to be finished at the end of the month and I
v wasted a week on this nonsense already :(is anyone Else having a similar problem at all?
Understand frustration. I do not have mega1284p chips but trying to help. Just try the code below.
~~~~
;Chip Settings
chip mega1284p,16
;Defines (Constants)
define LCD_IO 8
define LCD_DATA_PORT portc
define LCD_RS PORTD.5
define LCD_RW PORTD.4
define LCD_Enable PORTD.3
dir portb in
dir porta in
cls
main:
cls
lcdint (portb)
value = porta
locate 1,0
print value
wait 200 ms
goto main
Maybe try to approach this by accessing the atmega 2560 port registers
poke (1,0) 'set all port A pins direction in
poke (4,0) 'set all port B pins direction in
' lcd code here
MyPortA= peek(0) 'raw read portA input register
MyPortB= peek(3) 'raw read portB input register
print MyPortA
print MyPortB
Last edit: Rikki 2013-10-18
4 compile errors...
error: GCASM: Symbol MEMADR has not been defined
same with MEMADR_H, MEMDATA and also PEEK.
the 1284P is my own chipdata, but I`m having the same problem with PIC chips too so I can pretty much rule that out.
Anobium, your program didn
t work either (even after i added the #
s for the defines).Give me one hour. I will do a test compile using my config.
I have compiled with no errors.
Please attach your chip file. I can only test with my chip files. I chose a 16F1937... not your chipset. :-(
Hi the poke /peek command doesn't like leading zeros.
I have edited the post to use decimal instead....maybe try to compile your code again
the 1284P chipfile is attatched.
I had no problem compiling with Any chipset (PIC or Atmega), only the one that had the "Peek" commands in them,it Should work (and indeed used to work) using any of the code I posted in this thread.
meanwhile I
v found a pair of laptops that have never had GCB on them before, so I
m going to try a 100% fresh instal on one and see how that goes.Compiles with no errors.
I
v finally found a workaround after much messing about with code (which I didn
t want to do hence I choose to use Basic).DDRB = 0XFF
DDRD = 0X00
START:
Test = PIND
PORTB = Test
goto START:
This seems to work perfectly well, but I
v still got no idea why the same in pure Basic won
t work though?I`v also managed to get a 16F57 chip to work from pure basic, but Only after I read the chip from the PK2 software will the chip actually start to work as programmed.
Something somewhere is broken.
Check your circuit very carefully. Do you have a decoupler capactitor? Common 0v rails?
yup, all is perfect h/ware wise, I
v tried many different boards and ICs too. the Problem that I can see so far as I
m trying to lock it down, is the PORT command.the DIR PORT x In/Out is fine (so no need for the DDRx)
and if I replace PORT
x
with PINx
all works as it should when trying to Read a port.if you
re Outputting to a port, then fine, you can use PORT
x, but it
s no good anymore to Read a whole port.I really sorry but I cannot follow/fully understand the post.
My summary.
dir portx in|out works as expected. When you read and write the assigned port respectively.
dir pinx in|out only works when reading a pin. But, you have issues when reading pins? or do you mean reading a port?
sorry, my bad.
yes you can set the port Dir as normal.
and you can Output to a port as normal too.
but if you want to Read an entire port you can`t use the Port command, ie;
Var = PORTD will not work
instead I have to use;
var = PIND
Can you post you code please? I am sure you have something here.
sure, this code works:
now the Same thing using PORTD does Not work:
edited by Anobium to correct code layout.
Last edit: Anobium 2013-11-01
I am not AVR expert but reviewing http://www.atmel.com/Images/doc2466.pdf and https://ccrma.stanford.edu/wiki/AVR_Programming#AVR_Registers it looks like PORTD is a macro not an address so your method of using PINx is correct.