Menu

can`t read any port?

YT2095
2013-10-14
2013-11-01
<< < 1 2 (Page 2 of 2)
  • YT2095

    YT2095 - 2013-11-01

    so it`ll work for PIC not AVR, unless you use it to read a single pin, such as:

    var = portd.1 '(this works on AVR)

    will read pin 1 of port d on an AVR or PIC, but to read a Whole port you have to use PINx on avr.

    I`ll have to keep a note of that then, esp as I often swap my code between PIC and AVR regularly.

    Thanks for the help and patience! ;)

     
  • Hugh Considine

    Hugh Considine - 2013-11-01

    I think I can see the problem here. On an AVR, ports are read with PINx and written to with PORTx. Reading from PORTx will give the value of the output latch, similar to LATx on a PIC. But to provide better compatibility with PIC, GCBASIC is meant to translate the variable names so that reading PORTx will give the actual pin values on PIC or AVR, and reading/writing LATx will give the latch values. (So on AVR, if you read from PORTx, the compiler will change it to PINx, and if you read or write to LATx, the compiler will change it to PORTx. Writes to PORTx are not changed.)

    For some reason, that translation isn't working here, and the compiler is not changing PORTx to PINx where it should. I will look at it this weekend and hopefully fix it!

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.