Menu

Array Allocation Hiccup?

kent_twt4
2014-03-11
2014-05-10
  • kent_twt4

    kent_twt4 - 2014-03-11

    GCB seems to be coughing on Ram allocation. I'm using a 18f26k22 which has a ton of Ram (3896 Bytes). Tried using At Location, and same problem. The array size works fine till it gets up to 199, then compiler gives the following error message:

    Aborting due to runtime error 6 (out of bounds array access) at line 694 of F:/Robotics/GCBASIC/variables.bi::ALLOCATERAM()

    I'm using Steini's SynWrite GCB version (.9 22/9/2013). Tried an old GLCD program that used to work fine with an Atmega168 and 255 byte arrays back in early 2010, and get the same error now too. Here's the start of the program:

    'Chip model, Oscillator frequency FOSC
    #chip 18f26k22,4
    #config OSC=INTIO67
    
    'Setup 4 bit LCD
    #define LCD_IO 4
    #define LCD_DB4 PORTB.4
    #define LCD_DB5 PORTB.5
    #define LCD_DB6 PORTB.6
    #define LCD_DB7 PORTB.7
    #define LCD_RS PORTC.5
    #define LCD_RW PORTC.6
    #define LCD_Enable PORTC.7
      '#include <NewReadtemp.h>
      '#define ds18b20
      '#define OWDevice ds18b20
      '#define ReadTemp_9Bits       'Want to read 1/2 degree resolution
    'make use of the ReadTemp_Neg (True) Flag for negative temperatures
    
    Dim DummyRead As Word
    Dim HighLow As Word
    
    #define DQ PortA.2
    '=========ROM Commands for 1-Wire DS18S20 DS18B20======================================
    #define SearchRom 240   '0xF0 Identify Slave Rom codes
    #define ReadRom 51      '0x33 Command for single slave
    #define MatchRom 85 '0x55 To identify a specific slave code
    #define SkipRom 204 '0xCC Address all devices simultaneously
    #define AlarmSearch 236 '0xEC Search Rom to identify any alarm flags
    '==========Function Commands for for 1-Wire DS18S20 DS18B20=============================
    #define ConvertT 68 '0x44 Single Temp Conversion
    #define WriteScratch 78 '0x4E Write Scratchpad
    #define ReadScratch 190 '0xBE Read Scratchpad
    #define CopyScratch  72     '0x48 Copying Scratchpad TH and TL registers to EEPROM
    #define RecallE2 187    '0xB8 Recalling alarm trigger values from EEPROM
    
    #define FindDevices
    dim RomNum(8)
    dim Dev1Rom(8)
    dim Dev2Rom(8)
    dim Dev3Rom(8)
    Dim Dev4Rom(8)
    dim Dev5Rom(8)
    dim Dev6Rom(8)
    dim Dev7Rom(8)
    Dim Dev8Rom(8)
    Dim OWCRC(255) 'At 512
    'OWCRC(0) = 0x00
    OWCRC(1) = 94
    OWCRC(2) = 188
    OWCRC(3) = 226
    OWCRC(4) = 97
    OWCRC(5) = 63
    OWCRC(6) = 221
    OWCRC(7) = 131
    OWCRC(8) = 194
    OWCRC(9) = 156
    OWCRC(10) = 126
    OWCRC(11) = 32
    OWCRC(12) = 163
    OWCRC(13) = 253
    OWCRC(14) = 31
    OWCRC(15) = 65
    OWCRC(16) = 157
    OWCRC(17) = 195
    OWCRC(18) = 33
    OWCRC(19) = 127
    OWCRC(20) = 252
    OWCRC(21) = 162
    OWCRC(22) = 64
    OWCRC(23) = 30
    OWCRC(24) = 95
    OWCRC(25) = 1
    OWCRC(26) = 227
    OWCRC(27) = 189
    OWCRC(28) = 62
    OWCRC(29) = 96
    OWCRC(30) = 130
    OWCRC(31) = 220
    OWCRC(32) = 35
    OWCRC(33) = 125
    OWCRC(34) = 159
    OWCRC(35) = 193
    OWCRC(36) = 66
    OWCRC(37) = 28
    OWCRC(38) = 254
    OWCRC(39) = 160
    OWCRC(40) = 225
    OWCRC(41) = 191
    OWCRC(42) = 93
    OWCRC(43) = 3
    OWCRC(44) = 128
    OWCRC(45) = 222
    OWCRC(46) = 60
    OWCRC(47) = 98
    OWCRC(48) = 190
    OWCRC(49) = 224
    OWCRC(50) = 2
    OWCRC(51) = 92
    OWCRC(52) = 223
    OWCRC(53) = 129
    OWCRC(54) = 99
    OWCRC(55) = 61
    OWCRC(56) = 124
    OWCRC(57) = 34
    OWCRC(58) = 192
    OWCRC(59) = 158
    OWCRC(60) = 29
    OWCRC(61) = 67
    OWCRC(62) = 161
    OWCRC(63) = 255
    OWCRC(64) = 70
    OWCRC(65) = 24
    OWCRC(66) = 250
    OWCRC(67) = 164
    OWCRC(68) = 39
    OWCRC(69) = 121
    OWCRC(70) = 155
    OWCRC(71) = 197
    OWCRC(72) = 132
    OWCRC(73) = 218
    OWCRC(74) = 56
    OWCRC(75) = 102
    OWCRC(76) = 229
    OWCRC(77) = 187
    OWCRC(78) = 89
    OWCRC(79) = 7
    OWCRC(80) = 219
    OWCRC(81) = 133
    OWCRC(82) = 103
    OWCRC(83) = 57
    OWCRC(84) = 186
    OWCRC(85) = 228
    OWCRC(86) = 6
    OWCRC(87) = 88
    OWCRC(88) = 25
    OWCRC(89) = 71
    OWCRC(90) = 165
    OWCRC(91) = 251
    OWCRC(92) = 120
    OWCRC(93) = 38
    OWCRC(94) = 196
    OWCRC(95) = 154
    OWCRC(96) = 101
    OWCRC(97) = 59
    OWCRC(98) = 217
    OWCRC(99) = 135
    OWCRC(100) = 4
    OWCRC(101) = 90
    OWCRC(102) = 184
    OWCRC(103) = 230
    OWCRC(104) = 167
    OWCRC(105) = 249
    OWCRC(106) = 27
    OWCRC(107) = 69
    OWCRC(108) = 198
    OWCRC(109) = 152
    OWCRC(110) = 122
    OWCRC(111) = 36
    OWCRC(112) = 248
    OWCRC(113) = 166
    OWCRC(114) = 68
    OWCRC(115) = 26
    OWCRC(116) = 153
    OWCRC(117) = 199
    OWCRC(118) = 37
    OWCRC(119) = 123
    OWCRC(120) = 58
    OWCRC(121) = 100
    OWCRC(122) = 134
    OWCRC(123) = 216
    OWCRC(124) = 91
    OWCRC(125) = 5
    OWCRC(126) = 231
    OWCRC(127) = 185
    OWCRC(128) = 140
    OWCRC(129) = 210
    OWCRC(130) = 48
    OWCRC(131) = 110
    OWCRC(132) = 237
    OWCRC(133) = 179
    OWCRC(134) = 81
    OWCRC(135) = 15
    OWCRC(136) = 78
    OWCRC(137) = 16
    OWCRC(138) = 242
    OWCRC(139) = 172
    OWCRC(140) = 47
    OWCRC(141) = 113
    OWCRC(142) = 147
    OWCRC(143) = 205
    OWCRC(144) = 17
    OWCRC(145) = 79
    OWCRC(146) = 173
    OWCRC(147) = 243
    OWCRC(148) = 112
    OWCRC(149) = 46
    OWCRC(150) = 204
    OWCRC(151) = 146
    OWCRC(152) = 211
    OWCRC(153) = 141
    OWCRC(154) = 111
    OWCRC(155) = 49
    OWCRC(156) = 178
    OWCRC(157) = 236
    OWCRC(158) = 14
    OWCRC(159) = 80
    OWCRC(160) = 175
    OWCRC(161) = 241
    OWCRC(162) = 19
    OWCRC(163) = 77
    OWCRC(164) = 206
    OWCRC(165) = 144
    OWCRC(166) = 114
    OWCRC(167) = 44
    OWCRC(168) = 109
    OWCRC(169) = 51
    OWCRC(170) = 209
    OWCRC(171) = 143
    OWCRC(172) = 12
    OWCRC(173) = 82
    OWCRC(174) = 176
    OWCRC(175) = 238
    OWCRC(176) = 50
    OWCRC(177) = 108
    OWCRC(178) = 142
    OWCRC(179) = 208
    OWCRC(180) = 83
    OWCRC(181) = 13
    OWCRC(182) = 239
    OWCRC(183) = 177
    OWCRC(184) = 240
    OWCRC(185) = 174
    OWCRC(186) = 76
    OWCRC(187) = 18
    OWCRC(188) = 145
    OWCRC(189) = 207
    OWCRC(190) = 45
    OWCRC(191) = 115
    OWCRC(192) = 202
    OWCRC(193) = 148
    OWCRC(194) = 118
    OWCRC(195) = 40
    OWCRC(196) = 171
    OWCRC(197) = 245
    OWCRC(198) = 23
    OWCRC(199) = 73
    'OWCRC(200) = 8
    'OWCRC(201) = 86
    'OWCRC(202) = 180
    'OWCRC(203) = 234
    'OWCRC(204) = 105
    'OWCRC(205) = 55
    'OWCRC(206) = 213
    'OWCRC(207) = 139
    'OWCRC(208) = 87
    'OWCRC(209) = 9
    'OWCRC(210) = 235
    'OWCRC(211) = 181
    'OWCRC(212) = 54
    'OWCRC(213) = 104
    'OWCRC(214) = 138
    'OWCRC(215) = 212
    'OWCRC(216) = 149
    'OWCRC(217) = 203
    'OWCRC(218) = 41
    'OWCRC(219) = 119
    'OWCRC(220) = 244
    'OWCRC(221) = 170
    'OWCRC(222) = 72
    'OWCRC(223) = 22
    'OWCRC(224) = 233
    'OWCRC(225) = 183
    'OWCRC(226) = 85
    'OWCRC(227) = 11
    'OWCRC(228) = 136
    'OWCRC(229) = 214
    'OWCRC(230) = 52
    'OWCRC(231) = 106
    'OWCRC(232) = 43
    'OWCRC(233) = 117
    'OWCRC(234) = 151
    'OWCRC(235) = 201
    'OWCRC(236) = 74
    'OWCRC(237) = 20
    'OWCRC(238) = 246
    'OWCRC(239) = 168
    'OWCRC(240) = 116
    'OWCRC(241) = 42
    'OWCRC(242) = 200
    'OWCRC(243) = 150
    'OWCRC(244) = 21
    'OWCRC(245) = 75
    'OWCRC(246) = 169
    'OWCRC(247) = 247
    'OWCRC(248) = 182
    'OWCRC(249) = 232
    'OWCRC(250) = 10
    'OWCRC(251) = 84
    'OWCRC(252) = 215
    'OWCRC(253) = 137
    'OWCRC(254) = 107
    'OWCRC(255) = 53
    

    Edit: My Bad, changed At location syntax to no brackets. Still same problem.

     

    Last edit: kent_twt4 2014-03-12
  • Anobium

    Anobium - 2014-05-09

    Fixed in May 2014 release.

     
  • kent_twt4

    kent_twt4 - 2014-05-09

    Thanks Evan, this works great when doing bmp to array file conversions, like for animations on a GLCD.

     
  • Chuck Hellebuyck

    Do you have bmp graphics working on a GLCD?
    I tried to create the great cow symbol on my ks0108 GLCD but couldn't get it to work.

     
  • kent_twt4

    kent_twt4 - 2014-05-10

    Yes Chuck, I need to port the code over to the new glcd.h It shows the great cow bmp skipping across the screen and then reappearing, over and over. Kind of crude. Can't remember the frames per second, but more than fast enough. You can actually go too fast, and the effects look kind of smeared.

    To be clear, I don't have an app that does the bmp to glcd array in GCBasic. Came pretty close to making one with Python and the PIL library, just didn't finish it off. Instead I took one of the free online bmp to lcd array converters (bitmap2LCD), and hand transferred that to a couple of tables, then on into an array for fast execution.

    I will try and put up some cleaned up code when I get a chance, or you can try the following code which is in "very" rough shape. The cow was made into a jersey cow with a bitmap editor I believe.

     

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.